mysql - creating entry into ladp directory using python -
i trying create entry ldap using python gives me error {'info': 'no global superior knowledge', 'desc': 'server unwilling perform'} following code this
import ldap import ldap.modlist modlist fname="dayanand" lname="dayanand" username="dayanand" employee_num='102' domain="gmail.com" base_dn="xyz" l = ldap.initialize("ldap://localhost") l.simple_bind_s("cn=admin,dc=somnath,dc=zankar,dc=org","zankar") user_dn = "cn=admin,dc=somnath,dc=org" user_attrs = {} #user_attrs['objectclass'] = \ # ['top', 'person', 'organizationalperson', 'user'] user_attrs['cn'] = fname + ' ' + lname #user_attrs['userprincipalname'] = username + '@' + domain #user_attrs['samaccountname'] = username user_attrs['givenname'] = fname user_attrs['sn'] = lname user_attrs['displayname'] = fname + ' ' + lname #user_attrs['useraccountcontrol'] = '514' user_attrs['mail'] = username + '@host.com' #user_attrs['employeeid'] = employee_num user_attrs['homedirectory'] = '\\\\server\\' + username #user_attrs['homedrive'] = 'h:' #user_attrs['scriptpath'] = 'logon.vbs' user_ldif = modlist.addmodlist(user_attrs) # convert our dict nice syntax add-function using modlist-module ldif = modlist.addmodlist(user_attrs) # actual synchronous add-operation ldapserver try: l.add_s(user_dn,ldif) except ldap.ldaperror, error_message: print "error adding new user: %s" % error_message
what directory tree in ldap instance? ask because you're trying bind dc=somnath,dc=zankar,dc=org:
l.simple_bind_s("cn=admin,dc=somnath,dc=zankar,dc=org","zankar")
but you're trying add dc=somnath,dc=org:
user_dn = "cn=admin,dc=somnath,dc=org"
and error 'no global superior knowledge' can seen when trying add entry part of directory not exist.
you create new base dn of dc=somnath,dc=org, or try add entry dc=somnath,dc=zanker,dc=org. note try add entry not cn=admin, since presumably exists, using bind() service.
Comments
Post a Comment