Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to modify 'cn' attribute via ldap3 module, Python 3.x

I'm trying to modify 'cn' attribute of a user in Active Directory domain but it fails. Also I can't add add this attribute during the user creation process. It shows this error:

{'result': 67, 'description': 'notAllowedOnRDN', 'dn': '', 'message': 
'000020B1: UpdErr: DSID-030F1087, problem 6004 (CANT_ON_RDN), data 0\n\x00', 
'referrals': None, 'type': 'modifyResponse'}

My code:

def ad_connect():
    server = Server(ADSERVER, use_ssl=True, port=636, get_info=ALL)
    conn = Connection(server, SU_LOGIN, SU_PASS, auto_bind=True, 
                      check_names=True)
    return conn
connect = ad_connect()
...
user_dn = "CN=full.name,OU=Users,DC=test,DC=com"
cn = {'cn': (MODIFY_REPLACE, 'Full Name')} # it must be "Full Name" instead of "full.name"
connect.modify(user_dn, changes=cn) 
...
connect.unbind()

Is there any way to perform this modification? There are no issues with creating the user without this attribute, by the way.

like image 757
Anton Belov Avatar asked Oct 20 '25 15:10

Anton Belov


1 Answers

I've figured out! There is a 'modify_dn' option in ldap3 module.

connect.modify_dn(user_dn, NEW_DN)
like image 179
Anton Belov Avatar answered Oct 23 '25 05:10

Anton Belov



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!