我想使用LDIF文件來測試Spring的LDAP。如何在LDIF文件中添加屬性?
我不使用xml。
我實現了從LDIF文件中讀取所有的基本屬性。
如何添加一些自定義屬性?
到目前爲止,我用這個語法
dn: cn=name,ou=people,dc=springframework,dc=org
objectclass: top
objectclass: person
cn: name
sn: name
uid: name
mail: [email protected]
givenName: name
userPassword: namespassword
changetype: modify
add: telephonenumber
telephonenumber: 555-2468
...但它無法讀取該文件,因爲它不承認「一changeType」屬性。
編輯問題
我有這個文件:
dn: dc=springframework,dc=org
objectclass: top
objectclass: domain
objectclass: extensibleObject
dc: springframework
dn: ou=groups,dc=springframework,dc=org
objectclass: top
objectclass: organizationalUnit
ou: groups
dn: ou=subgroups,ou=groups,dc=springframework,dc=org
objectclass: top
objectclass: organizationalUnit
ou: subgroups
dn: ou=people,dc=springframework,dc=org
objectclass: top
objectclass: organizationalUnit
ou: people
dn: ou=space cadets,dc=springframework,dc=org
objectclass: top
objectclass: organizationalUnit
ou: space cadets
dn: ou=\"quoted people\",dc=springframework,dc=org
objectclass: top
objectclass: organizationalUnit
ou: "quoted people"
dn: ou=otherpeople,dc=springframework,dc=org
objectclass: top
objectclass: organizationalUnit
ou: otherpeople
dn: uid=ben,ou=people,dc=springframework,dc=org
objectclass: top
objectclass: person
objectclass: organizationalPerson
objectclass: inetOrgPerson
cn: Ben Alex
sn: Alex
uid: ben
userPassword: {SHA}nFCebWjxfaLbHHG1Qk5UU4trbvQ=
dn: uid=bob,ou=people,dc=springframework,dc=org
objectclass: top
objectclass: person
objectclass: organizationalPerson
objectclass: inetOrgPerson
cn: Bob Hamilton
sn: Hamilton
uid: bob
userPassword: bobspassword
dn: uid=joe,ou=otherpeople,dc=springframework,dc=org
objectclass: top
objectclass: person
objectclass: organizationalPerson
objectclass: inetOrgPerson
cn: Joe Smeth
sn: Smeth
uid: joe
userPassword: joespassword
dn: cn=mouse\, jerry,ou=people,dc=springframework,dc=org
objectclass: top
objectclass: person
objectclass: organizationalPerson
objectclass: inetOrgPerson
cn: Mouse, Jerry
sn: Mouse
uid: jerry
userPassword: jerryspassword
dn: cn=slash/guy,ou=people,dc=springframework,dc=org
objectclass: top
objectclass: person
objectclass: organizationalPerson
objectclass: inetOrgPerson
cn: slash/guy
sn: Slash
uid: slashguy
mail: [email protected]
givenName: Slash Snakepit
userPassword: slashguyspassword
msExchUserAccountControl: 0
dn: cn=quote\"guy,ou=\"quoted people\",dc=springframework,dc=org
objectclass: top
objectclass: person
objectclass: organizationalPerson
objectclass: inetOrgPerson
cn: quote\"guy
sn: Quote
uid: quoteguy
userPassword: quoteguyspassword
dn: uid=space cadet,ou=space cadets,dc=springframework,dc=org
objectclass: top
objectclass: person
objectclass: organizationalPerson
objectclass: inetOrgPerson
cn: Space Cadet
sn: Cadet
uid: space cadet
userPassword: spacecadetspassword
dn: cn=developers,ou=groups,dc=springframework,dc=org
objectclass: top
objectclass: groupOfUniqueNames
cn: developers
ou: developer
uniqueMember: uid=ben,ou=people,dc=springframework,dc=org
uniqueMember: uid=bob,ou=people,dc=springframework,dc=org
dn: cn=managers,ou=groups,dc=springframework,dc=org
objectclass: top
objectclass: groupOfUniqueNames
cn: managers
ou: manager
uniqueMember: uid=ben,ou=people,dc=springframework,dc=org
uniqueMember: cn=mouse\, jerry,ou=people,dc=springframework,dc=org
dn: cn=submanagers,ou=subgroups,ou=groups,dc=springframework,dc=org
objectclass: top
objectclass: groupOfUniqueNames
cn: submanagers
ou: submanager
uniqueMember: uid=ben,ou=people,dc=springframework,dc=org
而且我有這樣的例外:
產生的原因:com.unboundid.ldap.sdk.LDAPException:無法添加條目 'cn = slash/guy,ou = people,dc = springframework,dc = org',因爲它違反了 提供的模式:條目包含屬性 未在架構中定義的msExchUserAccountControl。
如何添加該屬性?
你們是不是要使用LDIF修改現有的LDAP ENTR y,還是您實際上有一個屬性,稱爲「changetype」,您嘗試通過LDIF創建新的LDAP條目時設置? – ChadSikorra
我正在嘗試創建與我具有相同的LDAP結構,但此LDIF文件是僅用於JUNIT測試的新文件。 我有需要添加其他屬性,這是自定義屬性。 – pacio14
我的目標是將一些自定義屬性添加到LDAP條目中,我認爲「changetype」是... 如果還有其他方式添加它們,請告訴我。 – pacio14