python-script を使用して、既存のユーザーに属性を追加しています。既存のユーザーはすでに次のとおりです:-
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)
与える
[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
].
スクリプトから新しい属性を追加したい:-
givenName: first_name which is XXX
Email: official_email which is xx@gmail.com