Active Directory LDAP move user to different OU - Ruby

心不动则不痛 提交于 2019-12-10 17:08:41

问题


I have hit a snag in my integration with Active Directory. I need to be able to move users from one OU to another. I'm using net-ldap 0.5.0 which is on github master branch and dug around in the source code and found out you could do this

$ldap.rename(
             olddn: "cn=bradford ricechip,ou=agents,ou=ihs,ou=test environment,dc=ctatechs,dc=com", 
             newrdn: "cn=bradford ricechip", 
             new_superior: "ou=coach,ou=ihs,ou=test environment,dc=ctatechs,dc=com"
) 

I'm getting: #<OpenStruct code=53, error_message="00000057: LdapErr: DSID-0C090A95, comment: Old RDN must be deleted, data 0, v1772\x00", matched_dn="", message="Unwilling to perform"> . I guess I don't understand how I can delete the old RDN then move the user to a new OU.

This is the only issue I'm having. If I need to provide anything else just let me know. Thanks in advance for all of the help!


回答1:


This is how we solved it:

@ldap.rename(
  olddn: user.dn, 
  newrdn: "CN=#{user.cn}", 
  delete_attributes: true, 
  new_superior: "#{new_ou}"
)

We also used the version of ldap-ruby on Github not the version on RubyGems.



来源:https://stackoverflow.com/questions/18129004/active-directory-ldap-move-user-to-different-ou-ruby

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!