2013-09-27 3 views
0

Есть ли способ настроить ActiveLdap с этим типом схемы.ActiveLdap Имеет способность создавать отношения между OU, имеет много Person и OU имеет много групп

* 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 
    |- ... 

Я пытаюсь использовать Somthing так:

class Domain < ActiveLdap::Base 
    ldap_mapping :dn_attribute => 'o', 
       :prefix => '', 
       :classes => %w(inetdomainauthinfo top maildomain organization) 
end 

Но я не могу понять, как правильно создать Person.rb.

ответ

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 
Смежные вопросы