Is there any function to add new attributes to all the existing user group in openladp using python script?

89 views Asked by At

I am using python-script to add attributes to the existing user. The existing user already as follows:-

import ldap3
search_base = 'ou=users,dc=ldap,dc=example,dc=com'
attrs = ['*']
search_filter = '(uid='+login+')' 
server = ldap3.Server(server_uri)
with ldap3.Connection(server, auto_bind=True) as conn:
    ldap_user = conn.search(search_base, search_filter, attributes=attrs)

gives

[DN: cn=Mr. XXX XX-*******04,ou=users,dc=ldap,dc=example,dc=com 
    cn: Mr. XXX XX-*******04 
    displayName: Mr. XXX XX
    gidNumber: 123
    homeDirectory: /home/users/*******04
    mobile: *******04
    objectClass: inetOrgPerson
                 posixAccount
                 top
                 pkiUser
                 person
                 organizationalPerson
    sn: Mr. XXX XX
    uid: *******04
    uidNumber: 123
].

I want to add new attributes to it from the script:-

givenName: first_name which is XXX
Email: official_email which is [email protected]
0

There are 0 answers