[Samba] Listing user...

Jeremy Allison jra at samba.org
Wed Oct 4 18:13:28 UTC 2017


On Wed, Oct 04, 2017 at 10:18:10AM +0100, Rowland Penny via samba wrote:
> On Wed, 4 Oct 2017 10:54:01 +0200
> Marco Gaiarin via samba <samba at lists.samba.org> wrote:
> 
> > Mandi! Rowland Penny via samba
> >   In chel di` si favelave...
> > 
> > > Why do you need a list of users ?
> > 
> > Because?! ;-)
> > 
> > I've coded some script in the past (eg, when i was using OpenLDAP and
> > samba in NT mode) that do something on the behalf of the users, ad i
> > was used to do a 'getent passwd' to have the list.
> > 
> 
> It is very easy to get a list of users from Samba AD with a simple
> script, you could use something like this:

Cool script Rowland, I've saved it off in my "useful scripts" folder :-).

Thanks,

	Jeremy.

> #!/bin/bash
> 
> DNSDOMAIN=$(hostname -d)
> 
> DC=$(host -t SRV _kerberos._udp.${DNSDOMAIN} | awk '{print $NF}'| sed
> 's/.$//' | head -n1 | awk -F '.' '{print $1}')
> 
> SUFFIX="dc=$(echo "${DNSDOMAIN}" | sed 's|\.|,dc=|g')"
> 
> ldbsearch -H ldap://${DC} -P -b "${SUFFIX}" -s sub
> "(&(objectClass=user)(!(objectClass=computer)))" samaccountname | grep
> sAMAccountName | sed "s|sAMAccountName: ||"
> 
> exit 0
> 
> Rowland
> 
> -- 
> To unsubscribe from this list go to the following URL and read the
> instructions:  https://lists.samba.org/mailman/options/samba



More information about the samba mailing list