problem description
when using python-ldap, there is a problem that you need to modify ou. Looking at the official python-ldap documentation, you can find that the function of rename_s () can solve this problem, but the ldap version used on the server does not support this operation.
thought that you can use search () to find user information, delete the user information under the original ou, and then use add () to add the user information to the new ou, but when you encounter a problem,: search () cannot find the attribute userpassword.
the environmental background of the problems and what methods you have tried
openldap version: openldap-2.4.44-15.el7_5.x86_64
python version: 2.7.5
related codes
/ / Please paste the code text below (do not replace the code with pictures)
def change_group(self, dn, newrdn, newsuperior=None, delold = 1):
"""
-sharp
:param dn:
:param newrdn:
:param newsuperior:
:param delold:
:return:
"""
dn_list = dn.split(",")
newsup_list = newsuperior.split(",")
if dn_list[1].strip() == newsup_list[0].strip():
return
try:
result = self.ldap_obj.rename_s(dn, newrdn, newsuperior, delold)
print result
except ldap.LDAPError, error_message:
print error_message
return False, []
else:
authority_str = ""
if (dn_list[1].strip() == "ou=Users") and (newsup_list[0].strip() == "ou=Admins"):
authority_str = "TRUE"
elif (dn_list[1].strip() == "ou=Admins") and (newsup_list[0].strip() == "ou=Users"):
authority_str = "FALSE"
-sharp authoritytouser
attr_list = [(ldap.MOD_REPLACE, "authoritytouser", authority_str)]
b, result = self.modify_user(dn, attr_list)
return b, result
what result do you expect? What is the error message actually seen?
error in using rename_s ():
{"info": u"cannot rename between DSAs"," desc": u"Operation affects multiple DSAs"}