添加条目postfix.ldif
[root@linux src]# ldapadd -x -D "cn=manager,dc=example,dc=net" -f postfix.ldif -w chen adding new entry "ou=people,dc=example,dc=net" adding new entry "ou=postfix,dc=example,dc=net" adding new entry "cn=courier, ou=postfix, dc=example,dc=net" [root@linux src]# ldapsearch -x -D 'cn=manager,dc=example,dc=net' -b 'dc=example,dc=net' 'objectclass=*' namingContexts -w chen version: 2 # # filter: objectclass=* # requesting: namingContexts # # example, net dn: dc=example,dc=net # System, example, net dn: ou=System, dc=example,dc=net # postfix, system, example, net dn: ou=postfix, ou=system, dc=example,dc=net # people, example, net dn: ou=people,dc=example,dc=net # postfix, example, net dn: ou=postfix,dc=example,dc=net # courier, postfix, example, net dn: cn=courier, ou=postfix, dc=example,dc=net # search result search: 2 result: 0 Success # numResponses: 7 # numEntries: 6 [root@linux src]# [root@linux src]# ldapsearch -x -D 'cn=manager,dc=example,dc=net' -b 'dc=example,dc=net' 'objectclass=*' -w chen version: 2 # # filter: objectclass=* # requesting: ALL # # example, net dn: dc=example,dc=net objectClass: person objectClass: organization cn: example sn: example o: example.net description:: VG9wIGxldmVsIG9mIGRpcmVjdG9yeSA= # System, example, net dn: ou=System, dc=example,dc=net userPassword:: cGFzc3dvcmQ= ou: system objectClass: organizationalUnit # postfix, system, example, net dn: ou=postfix, ou=system, dc=example,dc=net ou: postfix objectClass: organizationalUnit # people, example, net dn: ou=people,dc=example,dc=net ou: people objectClass: organizationalUnit # postfix, example, net dn: ou=postfix,dc=example,dc=net ou: postfix objectClass: organizationalUnit # courier, postfix, example, net dn: cn=courier, ou=postfix, dc=example,dc=net objectClass: person cn: courier sn: courier # search result search: 2 result: 0 Success # numResponses: 7 # numEntries: 6 [root@linux src]# |
添加用户users.ldif
[root@linux src]# ldapadd -x -D "cn=manager,dc=example,dc=net" -f users.ldif -w chen adding new entry "uid=chen,ou=postfix,dc=example,dc=net" [root@linux src]# ldapsearch -x -D 'cn=manager,dc=example,dc=net' -b 'dc=example,dc=net' 'cn=chen' -w chen version: 2 # # filter: cn=chen # requesting: ALL # # chen, postfix, example, net dn: uid=chen,ou=postfix,dc=example,dc=net uid: chen cn: chen sn: chen mail: [email protected] uidNumber: 1001 gidNumber: 1001 mailHost: mail.example.net homeDirectory: /home/chen mailMessageStore: /home/chen/maildir/ mailQuota: 200000000s,20000c mailbox: chen/maildir/ objectClass: qmailuser objectClass: couriermailaccount objectClass: person # search result search: 2 result: 0 Success # numResponses: 2 # numEntries: 1 [root@linux src]# |
使用kunmail.schema
[root@linux docbook]# cat kunmail.ldif dn: cn=chen, ou=kunmail, dc=example,dc=net objectClass: top objectClass: person objectClass: kunmailUser sn: kun cn: kunmail userNo: 1 userName: [email protected] userUid: 1000 userGid: 1000 userHome: /home/chen userMaildir: chen/Maildir userQuota: 200000000s,20000c userClearpw: chen userFullname: neo chen [root@linux docbook]# ldapadd -x -D'cn=manager,dc=example,dc=net' -w chen -f kunmail.ldif adding new entry "cn=chen, ou=kunmail, dc=example,dc=net" [root@linux docbook]# [root@linux docbook]# ldapsearch -x -D 'cn=manager,dc=example,dc=net' -b 'dc=example,dc=net' 'objectclass=*' -w chen version: 2 # # filter: objectclass=* # requesting: ALL # # example, net dn: dc=example,dc=net dc: example objectClass: dcObject objectClass: organization description: kunmail system made by YuCa Studio. o: YuCa Studio. # admin, example, net dn: ou=admin, dc=example,dc=net ou: admin objectClass: top objectClass: organizationalUnit # kunmail, example, net dn: ou=kunmail, dc=example,dc=net ou: kunmail objectClass: top objectClass: organizationalUnit # kunmail, admin, example, net dn: cn=kunmail, ou=admin, dc=example,dc=net userPassword:: Y3oyMDA0 objectClass: top objectClass: person sn: kun cn: kunmail # chen, kunmail, example, net dn: cn=chen, ou=kunmail, dc=example,dc=net objectClass: top objectClass: person objectClass: kunmailUser sn: kun cn: kunmail userNo: 1 userName: [email protected] userUid: 1000 userGid: 1000 userHome: /home/chen userMaildir: chen/Maildir userQuota:: MjAwMDAwMDAwcywyMDAwMGMg userClearpw: chen userFullname: neo chen # search result search: 2 result: 0 Success # numResponses: 6 # numEntries: 5 [root@linux docbook]# |
测试
[root@linux docbook]# ldapsearch -x -D 'cn=kunmail,ou=admin,dc=example,dc=net' -b 'dc=example,dc=net' 'cn=*' -w cz2004 version: 2 # # filter: cn=* # requesting: ALL # # kunmail, admin, example, net dn: cn=kunmail, ou=admin, dc=example,dc=net userPassword:: Y3oyMDA0 objectClass: top objectClass: person sn: kun cn: kunmail # chen, kunmail, example, net dn: cn=chen, ou=kunmail, dc=example,dc=net objectClass: top objectClass: person objectClass: kunmailUser sn: kun cn: kunmail userNo: 1 userName: [email protected] userUid: 1000 userGid: 1000 userHome: /home/chen userMaildir: chen/Maildir userQuota:: MjAwMDAwMDAwcywyMDAwMGMg userClearpw: chen userFullname: neo chen # search result search: 2 result: 0 Success # numResponses: 3 # numEntries: 2 [root@linux docbook]# |
创建.ldif 文件时,建议最好手工输入。不要使用复制,粘贴方法。
这里暂时使用qmail的schema有时间我会做一个postfix.schema标准的并且支持Foxmail,Outlook.
在添加过程中.ldif文件难免会出一些错误,这时会用到删除命令ldapdelete
[root@linux docbook]# ldapdelete -x -D'cn=manager,dc=example,dc=net' -w chen 'cn=chen, ou=kunmail, dc=example,dc=net' |