2015-05-10 62 views
0

我嘗試新的屬性添加到FreeIPA,我用「的ldapmodify」添加自定義屬性和對象類的LDAP,FreeIPA無法看到LDAP自定義屬性

#color.ldif 
dn: cn=schema 
changetype: modify 
add: attributeTypes 
attributeTypes: (2.25.28639311321113238241701611583088740684.14.2.2 
    NAME 'favoriteColorName' 
    EQUALITY caseIgnoreMatch SUBSTR caseIgnoreSubstringsMatch 
    SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 
    X-ORIGIN 'Extending FreeIPA') 

dn: cn=schema 
changetype: modify 
add: objectclasses 
objectclasses: (2.25.28639311321113238241701611583088740684.14.2.1 
    NAME 'customPerson' SUP person 
    STRUCTURAL 
    MAY (favoriteColorName) 
    X-ORIGIN 'Extending FreeIPA') 

然後重新啓動服務器和使用

ipa config-mod --addattr=ipaUserObjectClasses=customPerson 

的指示在Extending the FreeIPA Server,它出了所有罰款,終於我的插件添加到freeIPA

#color.py 
from ipalib.plugins import user 
from ipalib.parameters import Str 
from ipalib import _ 
user.user.takes_params = user.user.takes_params + (
    Str('favoritecolorname?', 
     cli_name='color', 
     label=_('Favorite color'), 
    ), 
) 
user.user.default_attributes.append('favoritecolorname') 

,當我嘗試運行命令:

ipa user-mod admin --color=red 

我得到的錯誤:

ipa: ERROR: attribute "favoriteColorName" not allowed

回答

1

,我發現我的問題的原因。看起來用戶'admin'沒有包含在其中的新創建的類'customPerson'。

[[email protected] ~]# ipa user-show admin --all 
    dn: uid=admin,cn=users,cn=accounts,dc=sample,dc=com 
    User login: admin 
    Last name: Administrator 
    Full name: Administrator 
    Home directory: /home/admin 
    GECOS: Administrator 
    Login shell: /bin/bash 
    Kerberos principal: [email protected] 
    UID: 1236600000 
    GID: 1236600000 
    Account disabled: False 
    Password: True 
    Member of groups: admins, trust admins 
    Kerberos keys available: True 
    objectclass: top, person, posixaccount, krbprincipalaux, krbticketpolicyaux, 
       inetuser, ipaobject, ipasshuser, ipaSshGroupOfPubKeys 

因此,任何嘗試使用未包含在這些對象類中的屬性都是不允許的。但修改爲其他用戶的顏色值被允許:

[[email protected] ~]# ipa user-mod test --color=blue 
-------------------- 
Modified user "test" 
-------------------- 
    User login: test 
    First name: test 
    Last name: test 
    Home directory: /home/test 
    Login shell: /bin/bash 
    Email address: [email protected] 
    UID: 1236600007 
    GID: 1236600007 
    Account disabled: False 
    Favorite color: blue 
    Password: True 
    Member of groups: ipausers 
    Kerberos keys available: True 
+1

是,現有的對象不被修改「自動的」,當新對象類變得可用(有在特定對象類的特定條目拍打沒有邏輯)。所以你需要改變回調的方式,以便在添加新屬性時修改對象類,如果對象類沒有這個類的話。 – abbra