我试图在AD中创建一个没有成功的组,下面是我的代码:
import ldap
import ldap.modlist as modlist
LDAPserver = 'hidden'
LDAPlogin = 'hidden'
LDAPpassword = 'hidden'
l = ldap.initialize('ldap://' + LDAPserver)
l.simple_bind_s(LDAPlogin, LDAPpassword)
dn = 'OU=someunit,OU=someunit,OU=someunit,OU=someunit,DC=my-company,DC=local'
attrs = {}
attrs['objectclass'] = ['top','Group']
attrs['cn'] = 'group name to be created'
attrs['description'] = 'Test Group'
ldif = modlist.addModlist(attrs)
l.add_s(dn,ldif)
l.unbind_s()下面的片段给出了一个错误:
ldap.INSUFFICIENT_ACCESS: {'info': '00000005: SecErr: DSID-031521D0, problem 4003
(INSUFF_ACCESS_RIGHTS), data 0\n', 'desc': 'Insufficient access'}但是,使用相同的凭据,我可以使用一些UI工具(如LDAP管理 )创建组
因此,我假设我有创建组的适当权限,但是python仍然没有成功。
我还可以查询现有组并通过脚本获取其成员。
我认为问题在于我的属性,也许Active Directory需要将一些不同的值插入到attrs变量中。广告运行在Win Server 2012 R2下。
如能提供任何帮助,将不胜感激:)
发布于 2022-07-05 10:07:21
dn实际上应该是CN=<groupname> + base_dn,所以在您的例子中,如下所示
dn = 'CN=groupname,OU=someunit,OU=someunit,OU=someunit,OU=someunit,DC=my-company,DC=local'发布于 2018-05-02 06:32:06
请尝试将LDAPlogin替换为完全绑定的dn值,如
"cn=hidden,dc=example,dc=com" https://stackoverflow.com/questions/44647934
复制相似问题