[Samba] ntfs user mappings?

Rowland Penny rpenny at samba.org
Mon Nov 6 11:29:49 UTC 2017


On Sun, 5 Nov 2017 16:14:33 -0700
Jeff Sadowski <jeff.sadowski at gmail.com> wrote:

> Not bad but I wanted an ldap version because I was having issues
> running ldbsearch as a normal user.
> 

I had another thought, why am I reinventing the wheel, so came up with
this:

#!/bin/bash

echo "#######################################################"
echo "#                                                     #"
echo "#      Please Wait whilst Usermap is created.         #"
echo "#                                                     #"
echo "#######################################################"

## Remove any existing usermap
if [ -f  /tmp/ntfs-3g.usermap ]; then
    rm -f /tmp/ntfs-3g.usermap
fi

WBINFO=$(which wbinfo)
if [ -z "${WBINFO}" ]; then
    echo
    echo "Cannot find 'wbinfo', is it installed?"
    echo "Cannot continue...Exiting"
    exit 1
fi

## Get users
ADUSERS=$(${WBINFO} -u)

## Get groups
ADGROUPS=$(${WBINFO} -g)

while IFS= read -r line
do
  SID=$(${WBINFO} -n "$line" | awk '{print $1}')
  echo "$line::$SID" >> /tmp/ntfs-3g.usermap
done <<< "$ADUSERS"

while IFS= read -r line
do
  SID=$(${WBINFO} -n "$line" | awk '{print $1}')
  echo ":$line:$SID" >> /tmp/ntfs-3g.usermap
done <<< "$ADGROUPS"

if [ -f /tmp/ntfs-3g.usermap ]; then
    echo
    echo "Usermap created in /tmp/ntfs-3g.usermap"
    echo
fi

exit 0

Anybody can run this, the only problem was '/etc/', only 'root' can
write into this directory, so I used '/tmp/' instead.

Rowland



More information about the samba mailing list