有没有办法用这种类型的方案配置ActiveLdap。
* dc=example,dc=com
|+ o=domain1.com,dc=example,dc=com
\
|+ ou=People,o=domain1.com,dc=example,dc=com
\
|- cn=user1,ou=People,o=domain1.com,dc=example,dc=com
|- cn=user2,ou=People,o=domain1.com,dc=example,dc=com
|- ...
|+ ou=Groups,
\
|- cn=group1,ou=Groups,o=domain1.com,dc=example,dc=com
|- cn=group2,ou=Groups,o=domain1.com,dc=example,dc=com
|- ...
|- o=otherdomain.com,dc=example,dc=com
\
|+ ou=People,o=otherdomain.com,dc=example,dc=com
\
|- cn=user1,ou=People,o=otherdomain.com,dc=example,dc=com
|- cn=user2,ou=People,o=otherdomain.com,dc=example,dc=com
|- ...
|+ ou=Groups,
\
|- cn=group1,ou=Groups,o=otherdomain.com,dc=example,dc=com
|- cn=group2,ou=Groups,o=otherdomain.com,dc=example,dc=com
|- ...
我尝试使用这样的东西:
class Domain < ActiveLdap::Base
ldap_mapping :dn_attribute => 'o',
:prefix => '',
:classes => %w(inetdomainauthinfo top maildomain organization)
end
但我无法弄清楚如何正确创建Person.rb。
答案 0 :(得分:0)
找到答案,谢谢Kouhei。
class Domain < ActiveLdap::Base
ldap_mapping :dn_attribute => 'o',
:prefix => '',
:classes => %w(inetdomainauthinfo top maildomain organization)
def user(uid)
User.find(uid, :prefix => "ou=People,o=#{o}")
end
def users
User.all(:prefix => "ou=People,o=#{o}")
end
def group(cn)
Group.find(cn, :prefix => "ou=Groups,o=#{o}")
end
def groups
Group.all(:prefix => "ou=Groups,o=#{o}")
end
end
class Group < ActiveLdap::Base
ldap_mapping :dn_attribute => 'cn',
:prefix => '',
:classes => %w(inetlocalmailrecipient inetmailgroupmanagement
top inetmailgroup groupofuniquenames)
def domain
Domain.find(dn.rdns[2]['o'])
end
end
class User < ActiveLdap::Base
ldap_mapping :dn_attribute => 'uid',
:prefix => '',
:classes => %w(top userpresenceprofile inetadmin
organizationalperson person inetuser inetlocalmailrecipient inetorgperson
inetsubscriber inetmailuser)
def domain
Domain.find(dn.rdns[2]['o'])
end
end