Python 和 LDAP
2010-09-22 11:12:52 来源:WEB开发网步骤 6:使用 ldapadd 和 LDIF 文件在 LDAP 数据库中添加更多条目。注意,LDIF 代表 LDAP Data Interchange Format,这是用于对 LDAP 数据库进行大量更新的数据格式:
[root@domU ]# cat unisonis.ldif
dn: dc=unisonis,dc=com
objectclass: dcObject
objectclass: organization
o: Example Company
dc: unisonis
dn: cn=Manager,dc=unisonis,dc=com
objectclass: organizationalRole
cn: Manager
[root@domU ]# ldapadd -x -D "cn=Manager,dc=unisonis,dc=com" -W -f
unisonis.ldif
Enter LDAP Password:
adding new entry "dc=unisonis,dc=com"
adding new entry "cn=Manager,dc=unisonis,dc=com"
步骤 7:下一步是用示例条目填充 LDAP 目录。我们使用三个小丑的信息(灵感来源于 LDAP 文章 http://www.yolinux.com/TUTORIALS/LinuxTutorialLDAP.html):
[root@domU ]# cat stooges.ldif; # to conserve space, we show the LDAP data for
only one of the three stooges
dn: ou=MemberGroupA,dc=unisonis,dc=com
ou: MemberGroupA
objectClass: top
objectClass: organizationalUnit
description: Members of MemberGroupA
dn: ou=MemberGroupB,dc=unisonis,dc=com
ou: MemberGroupB
objectClass: top
objectClass: organizationalUnit
description: Members of MemberGroupB
dn: cn=Larry Fine,ou=MemberGroupA,dc=unisonis,dc=com
ou: MemberGroupA
o: stooges
cn: Larry Fine
objectClass: top
objectClass: person
objectClass: organizationalPerson
objectClass: inetOrgPerson
mail: LFine@unisonis.com
givenname: Larry
sn: Fine
uid: larry
homePostalAddress: 15 Cherry Ln. Plano TX 78888
postalAddress: 215 Fitzhugh Ave.
l: Dallas
st: TX
postalcode: 75226
telephoneNumber: (800)555-1212
homePhone: 800-555-1313
facsimileTelephoneNumber: 800-555-1414
userPassword: larrysecret
title: Account Executive
destinationindicator: /bios/images/lfine.jpg
[root@domU ]# ldapadd -x -D "cn=Manager,dc=unisonis,dc=com" -W -f stooges.ldif
更多精彩
赞助商链接