- 查询
$ ldapsearch -x -b "dc=mydomain,dc=com" -H ldap://tuxbldvm3:1389
$ ldapsearch -x -b "ou=people,dc=mydomain,dc=com" -H ldap://tuxbldvm3:1389
$ ldapsearch -x -b "uid=user1,ou=people,dc=mydomain,dc=com" -H ldap://tuxbldvm3:1389
- 增加元素
$ cat adduser.ldif
# create new
# replace to your own domain name for "dc=***,dc=***" section
dn: uid=user2,ou=people,dc=mydomain,dc=com
objectClass: inetOrgPerson
cn: commname2
sn: surname2
uid: user2
userPassword: {SSHA}BCxXdhHMsLP25F43RSoFL3XBZ9altoqO
$ ldapadd -x -D cn=admin,dc=mydomain,dc=com -H ldap://:1389 -w <password> -f adduser.ldif
- 修改属性
$ cat modifyuser.ldif
dn: uid=user2,ou=people,dc=mydomain,dc=com
changetype: modify
replace: userPassword
userPassword: {SSHA}Ccc/O1EUS50moS0XBVH9NXVGosWmGSTY
$ ldapmodify -H ldap://:1389 -x -D "cn=admin,dc=mydomain,dc=com" -w <password> -f modifyuser.ldif
修改多个属性:
$ cat modifyuser.ldif
dn: uid=user2,ou=people,dc=mydomain,dc=com
changetype: modify
replace: userPassword
userPassword: {SSHA}Ccc/O1EUS50moS0XBVH9NXVGosWmGSTY
-
replace: sn
sn: newsurname
$ ldapmodify -H ldap://:1389 -x -D "cn=admin,dc=mydomain,dc=com" -w <password> -f modifyuser.ldif
删除原始
$ cat modifyuser.ldif
dn: uid=user2,ou=people,dc=mydomain,dc=com
changetype: delete
$ ldapmodify -H ldap://:1389 -x -D "cn=admin,dc=mydomain,dc=com" -W -f ./modifyuser.ldif
网友评论