Python LDB authentication via LDAP

Amitay Isaacs amitay at
Thu Jan 5 18:39:09 MST 2012

Hi William,

On Fri, Jan 6, 2012 at 11:58 AM, William Brown
<william.e.brown at> 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, 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.

pydoc samba

Hope that gives you a starting point.


More information about the samba-technical mailing list