pythonldappython-3.5ldap3

Python 3.5, ldap3 and modify_password()


I've been pulling my hair out trying to send a request to update my own password via a script. here is the code:

#!/usr/bin/python3.5

from ldap3 import Server, Connection, NTLM, ALL

server = Server('ldap://192.168.0.80', use_ssl=True)

conn = Connection(server, user="local\\dctest", password="Pa55word1", authentication=NTLM, auto_bind=True)

dn = "CN=dctest,CN=Users,DC=home,DC=local"

conn.extend.microsoft.modify_password(dn, new_password="Pa55word2", old_password="Pa55word1")

The error that i get is:

{'dn': '', 'type': 'modifyResponse', 'description': 'unwillingToPerform', 'referrals': None, 'result': 53, 'message': '00002077: SvcErr: DSID-03190E44, problem 5003 (WILL_NOT_PERFORM), data 0\n\x00'}

Any idea what I'm doing wrong?

I have full access to the DC and I've made sure that the passwords are correct etc. I've read all the docs and just can't get my head around it.

any help would be great!!


Solution

  • OK thank you to everyone for your help, and the developers on github.

    the code i used to make this work in the end was...

    from ldap3 import Server, Connection
    
    server = Server('ldaps://<AD server address>', use_ssl=True)
    conn = Connection(server, user="<domain>\\<username>", password="<current password>", auto_bind=True)
    
    dn = 'CN=<username>,OU=Users,DC=<dominaname>'
    
    res = conn.extend.microsoft.modify_password(dn, old_password='<current password>', new_password='<new password>')
    print(res)
    

    Thought i'd post the working solution as there doesn't seem to be any on the internets!! God speed my fellow devops people.