[Samba] ntfs user mappings?

Rowland Penny rpenny at samba.org
Sat Nov 4 09:21:29 UTC 2017


On Fri, 3 Nov 2017 16:25:57 -0600
Jeff Sadowski <jeff.sadowski at gmail.com> wrote:

> That looks easier
> 
> I was working on ldap to convert but I'll try ldb-tools
> 
> I was off on a bash mission here is what I had so far it isn't correct
> so I'll keep working on it
> 
> #!/bin/bash
> if [ "$(echo $1|wc -c)" = "41" ];then
> hex=$(echo $1|base64 -d| od -x -w28 --endian=big|head -n1|sed
> 's/^0000000 //'|sed 's/ //g')
> echo ${hex}
> hex_chunk=$(echo ${hex}|cut -c1-2);
> echo ${hex_chunk}
> rev=$(echo "ibase=16; ${hex_chunk}" | bc)
> hex_chunk=$(echo ${hex}|cut -c3-4)
> echo ${hex_chunk}
> dashes=$(echo "ibase=16; ${hex_chunk}" | bc)
> hex_chunk=$(echo ${hex}|cut -c5-16)
> echo ${hex_chunk}
> notsure=$(echo "ibase=16; ${hex_chunk}" | bc)
> hex_chunk=$(echo ${hex}|cut -c17-24)
> echo ${hex_chunk}
> issuer1=$(echo "ibase=16; ${hex_chunk}" | bc)
> hex_chunk=$(echo ${hex}|cut -c25-32)
> echo ${hex_chunk}
> issuer2=$(echo "ibase=16; ${hex_chunk}" | bc)
> hex_chunk=$(echo ${hex}|cut -c33-40)
> echo ${hex_chunk}
> issuer3=$(echo "ibase=16; ${hex_chunk}" | bc)
> hex_chunk=$(echo ${hex}|cut -c41-48)
> echo ${hex_chunk}
> issuer4=$(echo "ibase=16; ${hex_chunk}" | bc)
> hex_chunk=$(echo ${hex}|cut -c49-57)
> uid=$(echo "ibase=16; ${hex_chunk}" | bc)
> left=$(echo ${hex}|cut -c58-)
> echo "[${left}]"
> echo
> "S-${rev}-${dashes}-${notsure}-${issuer1}-${issuer2}-${issuer3}-${issuer4}-${uid}"
> 
> else
> echo $1
> echo "not 41 characters like I was expecting"
> fi
> 

Hmm, you could do this instead:

#!/bin/bash

## Get users object into $1 with ldbsearch

SID=$(echo $1 | grep 'objectSid:' | awk '{print $NF}')
echo "$SID"

Which would result in something like this:

S-1-5-21-1768301897-3342589593-1064908849-1107

Rowland



More information about the samba mailing list