Ruby net-ldap add user

帅比萌擦擦* 提交于 2019-12-01 10:26:34

I had these issues aswell, last 2 days, but finally figured out a solution to make my user. Here is the working code for me:

ldap = Net::LDAP.new
        ldap.host = SERVER
        ldap.port = PORT
        ldap.authenticate login, pass        

dn = "cn=Pick Name, dc=example, dc=com"
                attr = {
                  :cn => "Pick Name",
                  :objectclass => "User",
                  :sn => 'Name',
                  :telephoneNumber => "12345678",
                  :mail => "gsmith@example.com"
                }
    ldap.add(:dn => dn, :attributes => attr)

The thing I think that has given me issues is the ObjectClass .. In the object class you write in the Type thats set in your AD. So if you wanted an organizational Unit, it would look like this: :objectclass => "organizationalUnit" Also I think the CN in DN and attr needs to be identical.

Hope this helps

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