I'm trying to modify an user account password in but it doesn't work, I've tried it directly in AD and it does work. I'm using ldap3 to do it, here's the steps I do.
First I do the app operation like this
from ldap3 import Server, Connection, ALL
s = Server("ldap://192.168.x.xx", use_ssl=True)
c = Connection(s, user='adminldap', password='xxxxxxx')
c.bind()
c.add('cn=jtest,ou=users,ou=MJC,dc=mjc,dc=lan', ['user', 'posixGroup', 'top'], {'cn': 'jtest', 'sAMAccountName':'jtest', 'mail':'jtest@gmail.com','telephoneNumber':'0102030405','displayName':'jtest'})
This one works.
Then I try to set the password
Path_Root = "ou=users,ou=MJC,DC=mjc,DC=lan"
Filter = "(&(objectclass=user)(&(sAMAccountName=jtest)(!(objectclass=computer))))"
c.search(search_base = Path_Root,search_filter = Filter,attributes = ["cn", "sAMAccountName", "displayName"])
if len(c.entries) == 1:
USER_DN = c.response[0].get("dn")
c.extend.microsoft.modify_password(USER_DN, 'Formation123')
Like this but the last line keeps returning False.
Have you got an idea why ? Thank you.
the solution was setting ssl on my ldap and it worked.