背景: 我一直在我的Linux机器上使用python-ldap模块来管理远程Windows Server 2008上的用户帐户。我已经能够搜索,创建和修改用户,但更改用户的“ou”除外。
我尝试过使用'modify_s'和'modrdn_s',但由于modrdn只允许你改变dn的第一部分,我没有运气修改'ou'或将用户移动到新的'ou'。
暂时我正在创建一个新用户并从旧用户复制我能够的所有属性,然后删除旧用户。 但这不允许我保留用户创建日期和其他不可编辑的信息。
我已经彻底搜索了互联网并找到了一些解决方案,但是: 在其他操作系统上: 如何使用Python将用户移动到其他OU 和其他编程语言: Active Directory LDAP将用户移动到不同的OU - Ruby 这可能在Linux上的python-ldap中还是有任何解决方法? 谢谢!
Background: I have been using the python-ldap module on my Linux machine to manage user accounts on a remote Windows Server 2008. I have been able to search for, create, and modify users, with the exception of changing a user's 'ou'.
I have tried using 'modify_s' and 'modrdn_s' but since modrdn only allows you to change the first part of a dn, I haven't had luck modifying the 'ou' or moving a user to a new 'ou'.
Temporarily I am creating a new user and copying all the attributes that I am able to from the old user, then deleting the old user. But this doesn't allow me to retain the user creation date and other un-editable information.
I have thoroughly searched the internet and found a few solutions, but: on other operating systems: How do you move a user to a different OU using Python and other programming languages: Active Directory LDAP move user to different OU - Ruby Is this possible in python-ldap on Linux or are there any work-arounds? Thank you!
最满意答案
您需要使用rename_s并指定newsuperior参数。
快速示例代码:
ldap.rename_s('cn=UserName,ou=OldContainer,dc=example,dc=com', 'cn=UserName', 'ou=NewContainer,dc=example,dc=com')You need to use rename_s and specify the newsuperior parameter.
Quick sample code:
ldap.rename_s('cn=UserName,ou=OldContainer,dc=example,dc=com', 'cn=UserName', 'ou=NewContainer,dc=example,dc=com')更多推荐
发布评论