首页 > 代码库 > openldap 搭建

openldap 搭建

  • 和上次的不同:用rpm安装,且不用mysql做后端。

1. 软件安装:

yum -y install openldap-servers openldap-clients openldap openldap-devel migrationtools

2. 修改配置文件: /etc/openldap/slapd.conf (可以从 /usr/share/openldapservers/ 下面获取模板),去掉注释,就剩下面这些了:

include		/etc/openldap/schema/corba.schemainclude		/etc/openldap/schema/core.schemainclude		/etc/openldap/schema/cosine.schemainclude		/etc/openldap/schema/duaconf.schemainclude		/etc/openldap/schema/dyngroup.schemainclude		/etc/openldap/schema/inetorgperson.schemainclude		/etc/openldap/schema/java.schemainclude		/etc/openldap/schema/misc.schemainclude		/etc/openldap/schema/nis.schemainclude		/etc/openldap/schema/openldap.schemainclude		/etc/openldap/schema/ppolicy.schemainclude		/etc/openldap/schema/collective.schemaallow bind_v2pidfile		/var/run/openldap/slapd.pidargsfile	/var/run/openldap/slapd.argsloglevel	257TLSCACertificatePath /etc/openldap/certsTLSCertificateFile "\"OpenLDAP Server\""TLSCertificateKeyFile /etc/openldap/certs/passworddatabase configaccess to *	by dn.exact="gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth" manage	by * nonedatabase monitoraccess to *	by dn.exact="gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth" read        by dn.exact="cn=Manager,dc=my-domain,dc=com" read        by * nonedatabase	bdbsuffix		"dc=dns,dc=com,dc=cn"checkpoint	1024 15rootdn		"cn=Manager,dc=dns,dc=com,dc=cn"rootpw		secretdirectory	/var/lib/ldapindex objectClass                       eq,presindex ou,cn,mail,surname,givenname      eq,pres,subindex uidNumber,gidNumber,loginShell    eq,presindex uid,memberUid                     eq,pres,subindex nisMapName,nisMapEntry            eq,pres,sub
  • 复制数据库文件:
  • cp /usr/share/openldap-servers/DB_CONFIG.example /var/lib/ldap/DB_CONFIG;chown ldap:ldap /var/lib/ldap -R

3.导入base.ldif  (这一步很关键,我TM因为这个卡了半天)

  •  去 /usr/share/migrationtools/ , 修改 migrate_common.ph
  • 技术分享

     

  • 执行脚本:./migrate_base.pl > base.ldif
  • 编辑:base.ldif  (其实不编辑也可以,全部导入就好了)
dn: dc=dns,dc=com,dc=cndc: dnsobjectClass: topobjectClass: domaindn: ou=People,dc=dns,dc=com,dc=cnou: PeopleobjectClass: topobjectClass: organizationalUnitdn: ou=Group,dc=dns,dc=com,dc=cnou: GroupobjectClass: topobjectClass: organizationalUnit
dn: ou
=Hosts,dc=dns,dc=com,dc=cnou: HostsobjectClass: topobjectClass: organizationalUnit
  • 导入ldap:
  • 执行:  ldapadd -D "cn=Manager,dc=dns,dc=com,dc=cn" -w secret -c -x -f base.lldif
  • 这基础就算弄好了

4. 后续导入账户:

  • 只要随便编写一个ldif文件,用上面导入base.ldif的方式导入就可以了。

 

openldap 搭建