使用 Python 更新 AD 中的 LDAP 属性
Update LDAP attribute in AD with Python
当我尝试使用此代码更新 Active Directory 属性时:
dn = (
"CN=user_ldap,OU=dept_name,OU=Application,"
"OU=Service Accounts,OU=Domain Users,DC=company-corp,DC=global"
)
# define the server
server = ldap3.Server(
"ldaps.company-corp.global", get_info=ldap3.ALL, port=636, use_ssl=True
)
# define the connection
conn = ldap3.Connection(server, dn, psw, auto_bind=True)
conn.start_tls()
userID = "jdoe"
# perform the Modify operation
conn.modify(
f"CN={userID},OU=managed,OU=Domain Users,DC=company-corp,DC=global",
{"displayName": [(ldap3.MODIFY_REPLACE, ["Doe, John D"])]},
)
print(conn.result)
我收到以下错误:
{'result': 32, 'description': 'noSuchObject', 'dn': 'OU=Managed,OU=Domain Users,DC=company-corp,DC=global', 'message': "0000208D: NameErr: DSID-03100241, problem 2001 (NO_OBJECT), data 0, best match of:\n\t'OU=Managed,OU=Domain Users,DC=ssnc-corp,DC=global'\n\x00", 'referrals': None, 'type': 'modifyResponse'}
请指教
提前致谢。
NO_OBJECT错误一般表示指定DN的对象(本例为cn=jdoe,ou=managed,ou=domain users,dc=company-corp,dc=global)不能被发现。当服务帐户没有权限读取记录或完全限定的 DN 不正确时,可能会出现错误。
要消除不正确的完全限定 DN,您可以尝试搜索对象(例如搜索 sAMAccountName=LogonIDGoesHere)并检索 DN 值。
要消除访问权限,您可以使用 Active Directory 用户和计算机检查帐户对对象的有效权限。在“安全”选项卡上,单击“高级”。在高级安全设置window中,点击“有效访问”选项卡。单击 'select a user' link 到 select 您的服务帐户,然后单击“查看有效访问权限”以查看是否允许 'read all properties' 或 'read general information' 之类的内容。
当我尝试使用此代码更新 Active Directory 属性时:
dn = (
"CN=user_ldap,OU=dept_name,OU=Application,"
"OU=Service Accounts,OU=Domain Users,DC=company-corp,DC=global"
)
# define the server
server = ldap3.Server(
"ldaps.company-corp.global", get_info=ldap3.ALL, port=636, use_ssl=True
)
# define the connection
conn = ldap3.Connection(server, dn, psw, auto_bind=True)
conn.start_tls()
userID = "jdoe"
# perform the Modify operation
conn.modify(
f"CN={userID},OU=managed,OU=Domain Users,DC=company-corp,DC=global",
{"displayName": [(ldap3.MODIFY_REPLACE, ["Doe, John D"])]},
)
print(conn.result)
我收到以下错误:
{'result': 32, 'description': 'noSuchObject', 'dn': 'OU=Managed,OU=Domain Users,DC=company-corp,DC=global', 'message': "0000208D: NameErr: DSID-03100241, problem 2001 (NO_OBJECT), data 0, best match of:\n\t'OU=Managed,OU=Domain Users,DC=ssnc-corp,DC=global'\n\x00", 'referrals': None, 'type': 'modifyResponse'}
请指教
提前致谢。
NO_OBJECT错误一般表示指定DN的对象(本例为cn=jdoe,ou=managed,ou=domain users,dc=company-corp,dc=global)不能被发现。当服务帐户没有权限读取记录或完全限定的 DN 不正确时,可能会出现错误。
要消除不正确的完全限定 DN,您可以尝试搜索对象(例如搜索 sAMAccountName=LogonIDGoesHere)并检索 DN 值。
要消除访问权限,您可以使用 Active Directory 用户和计算机检查帐户对对象的有效权限。在“安全”选项卡上,单击“高级”。在高级安全设置window中,点击“有效访问”选项卡。单击 'select a user' link 到 select 您的服务帐户,然后单击“查看有效访问权限”以查看是否允许 'read all properties' 或 'read general information' 之类的内容。