Help needed for initializing SAMR connection against AD

Zahari Zahariev zahari.zahariev at postpath.com
Thu Jul 9 07:25:17 GMT 2009


Zahari Zahariev wrote:
> Hello team,
>
> What I am trying to do is to create a simple user in AD and then reset 
> it's password so that I am able to log in with it and do something as 
> that user. This is all to be done with Python bindings for a unittest.
>
> What I have done is that I create the user which is a breeze -- no 
> problem. Here comes the tricky part when I have to reset the password. 
> Number of ways to do it: Kerberos, SAMR etc. I chose SAMR because 
> there are already Python wrappings for it. There are number of code 
> examples in Samba like:
>
> source4/scripting/python/examples/samr.py
> source4/scripting/python/samba/tests/dcerpc/sam.py
> source4/scripting/python/samba/tests/dcerpc/bare.py
>
> I did looked in them all. Although I couldn't figure out how can I 
> authenticate against MS Active Directory server using it and then send 
> request to change password of a given user.
>
> If someone has any clue I would appreciate it.
>
> Regards,
>
> Zahari
>

Hello everyone,

I found the right way to do this:

    from samba.dcerpc import samr 
    from samba import credentials 
 
    cred = credentials.Credentials() 
    cred.set_username("admin") 
    cred.set_password("password")
     
    pipe = samr.samr("ncacn_ip_tcp:ip_addr", credentials=cred)

This popped up from the SummerOfCode lists. Thanks to Andrew it has been brought to my attention.

Regards,

	--Zahari




More information about the samba-technical mailing list