我必须像这样将一个organizationalunit
添加到新安装的OpenLDAP(在Ubuntu 12.04上):
dn: ou=MYREGION, ou=MYAPP, ou=GROUPS, o=myorganization, c=fr ou: MYREGION objectClass: top objectClass: organizationalunit
所以,因为它是一个新的LDAP,我想我必须首先添加fr
国家,我创build该文件:
dn: c=fr c: fr objectClass: top objectClass: country
现在我尝试使用该命令导入它(我没有该服务器的域):
ldapadd -x -D cn=admin,dc=nodomain -W -f country_fr.ldif
但OpenLDAP拒绝该命令:
adding new entry "c=fr" ldap_add: Server is unwilling to perform (53) additional info: no global superior knowledge
任何提示?
错误no global superior knowledge
意味着slapd
不知道在哪里把你的新条目。 这通常意味着你还没有定义一个合适的数据库。 对于较新的系统(使用cn=config
而不是slapd.conf
),通常首先使用ldapadd
或ldapmodify
添加新数据库或修改现有数据库条目。 例如,在我的Fedora 17系统上,默认安装设置一个像这样的数据库来托pipedc=my-domain,dc=com
:
dn: olcDatabase={2}hdb objectClass: olcDatabaseConfig objectClass: olcHdbConfig olcDatabase: {2}hdb olcDbDirectory: /var/lib/ldap olcDbIndex: objectClass eq,pres olcDbIndex: ou,cn,mail,surname,givenname eq,pres,sub structuralObjectClass: olcHdbConfig creatorsName: cn=config olcSuffix: dc=my-domain,dc=com olcRootDN: cn=Manager,dc=my-domain,dc=com
要托pipe您的组织( o=myorganization, c=fr
),我需要创build以下LDIF文件:
dn: olcDatabase={2}hdb,cn=config changetype: modify replace: olcSuffix olcSuffix: o=myorganization, c=fr - replace: olcRootDN olcRootDN: cn=Manager,o=myorganization,c=fr - replace: olcAccess olcAccess: {0}to * by dn.base="gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth" write by dn.base="cn=Manager,o=myorganization,c=fr" write by * none
然后我会像这样加载这些修改:
ldapmodify -Y EXTERNAL -H ldapi:/// -f mychanges.ldif
这是因为configuration中已经存在以下olcAccess
行:
dn: olcDatabase={0}config,cn=config objectClass: olcDatabaseConfig olcDatabase: {0}config olcAccess: {0}to * by dn.base="gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth" manage by * none
这会授予root
,通过ldapi:///
socket的slapd
ldapi:///
,无密码地访问cn=config
树。
然后我会加载我的顶级条目:
dn: o=myorganization, c=fr objectclass: organization o: myorganization
通过运行:
ldapadd -Y EXTERNAL -H ldapi:/// -f myobject.ldif
这是因为我已经为这个数据库添加了一个类似的ACL。 请注意,我不需要在此处以c=fr
开始,因为数据库被定义为保存o=myorganization,c=fr
感谢larsks答案 ,这是我做的。
首先这里是Ubuntu 12.04(文件/etc/ldap/slapd.d/cn=config/olcDatabase={1}hdb.ldif
)的默认configuration的摘录:
dn: olcDatabase={1}hdb objectClass: olcDatabaseConfig objectClass: olcHdbConfig olcDatabase: {1}hdb olcDbDirectory: /var/lib/ldap olcSuffix: dc=nodomain olcAccess: {0}to attrs=userPassword,shadowLastChange by self write by anonymou s auth by dn="cn=admin,dc=nodomain" write by * none olcAccess: {1}to dn.base="" by * read olcAccess: {2}to * by self write by dn="cn=admin,dc=nodomain" write by * read olcLastMod: TRUE olcRootDN: cn=admin,dc=nodomain
所以我创build了以下change_suffix.ldif
:
dn: olcDatabase={1}hdb,cn=config changetype: modify replace: olcSuffix olcSuffix: o=myorganization,c=fr - replace: olcRootDN olcRootDN: cn=admin,o=myorganization,c=fr - replace: olcAccess olcAccess: {0}to attrs=userPassword,shadowLastChange by self write by anonymous auth by dn="cn=admin,o=myorganization,c=fr" write by * none olcAccess: {2}to * by self write by dn="cn=admin,o=myorganization,c=fr" write by * read
并使用以下命令将其添加到我的ldap中:
sudo ldapmodify -Y EXTERNAL -H ldapi:/// -f change_suffix.ldif
现在我必须用下面的myorganization.ldif
创build组织节点:
dn: o=myorganization,c=fr objectclass: organization o: myorganization
最后用下面的命令添加它(第一个由于Insufficient access (50)
而不工作Insufficient access (50)
):
ldapadd -x -D cn=admin,o=myorganization,c=fr -W -f myorganization.ldif
现在我可以添加组织单位:
dn: ou=GROUPS, o=myorganization,c=fr ou: GROUPS objectClass: top objectClass: organizationalunit dn: ou=MYAPP, ou=GROUPS, o=myorganization,c=fr ou: MYAPP objectClass: top objectClass: organizationalunit dn: ou=MYREGION, ou=MYAPP, ou=GROUPS, o=myorganization,c=fr ou: MYREGION objectClass: top objectClass: organizationalunit