Python LDB authentication via LDAP

Andrew Bartlett abartlet at samba.org
Thu Jan 5 19:20:50 MST 2012


On Fri, 2012-01-06 at 12:39 +1100, Amitay Isaacs wrote:
> Hi William,
> 
> On Fri, Jan 6, 2012 at 11:58 AM, William Brown
> <william.e.brown at adelaide.edu.au> wrote:
> > Hi,
> >
> > I'm currently looking into writing some small python scripts to edit user information in samba4. I have been reading the C code for ldb, but am not quite sure how it authenticates to an ldap backend when used remotely. Any information on how to do this in python would be much appreciated. When used on the domain controller machine, which file should ldb be opening to edit the users partition?
> >
> > Sincerely,
> >
> > William Brown
> 
> You can use the python framework created for accessing most of the
> objects in samba4.
> There are plenty of examples in source4/scripting/python/samba/netcmd
> directory. For
> example, user.py provides interfaces to manipulate users.
> 
> To access AD database, you can use samba.samdb class. The url option specifies
> the location of the AD database. It can be either sam.ldb file or
> ldap://hostname url.
> 
> You can get information on various samba python interfaces using pydoc
> provided you
> set PYTHONPATH to the directory containing samba python modules.

Additionally, the python tests such as ldap.py demonstrate how to create
a credentials object and pass that to ldb/samdb.

Andrew Bartlett

-- 
Andrew Bartlett                                http://samba.org/~abartlet/
Authentication Developer, Samba Team           http://samba.org




More information about the samba-technical mailing list