add-user.ldif

dn: uid=ithelpdesk,ou=People,dc=example,dc=com
uid: ithelpdesk
objectClass: top
objectClass: account
objectClass: posixaccount
objectClass: inetOrgPerson
objectClass: person
objectClass: inetUser
objectClass: organizationalPerson
uidNumber: 1025
gidNumber: 101
homeDirectory: /home/ithelpdesk
loginShell: /bin/bash
userPassword: 123456
sn: IT
givenname: Helpdesk
cn: IT Helpdesk
l: Hangzhou
mail: ithelpdesk@example.com
description: ithelpdesk
~]# ldapadd -f add-user.ldif -h dsserver -p 389 -D "cn=Directory Manager" -x -W
Enter LDAP Password:
adding new entry "uid=ithelpdesk,ou=People,dc=example,dc=com"

add-group.ldif

dn: cn=users,ou=Groups,dc=example,dc=com
objectClass: top
objectClass: posixGroup
objectClass: groupOfUniqueNames
gidNumber:   101
cn: users
~]# ldapadd -f add-group.ldif -h dsserver -p 389 -D "cn=Directory Manager" -x -W
Enter LDAP Password:
adding new entry "cn=users,ou=Groups,dc=example,dc=com"

ldapadd ldapmodify ldapdelete

交互式操作

ldapmodify

# ldapmodify -D "cn=Directory Manager" -W -p 389 -h server.example.com -x
 
dn: uid=user,ou=people,dc=example,dc=com
changetype: modify
delete: telephoneNumber
-
add: manager
manager: cn=manager_name,ou=people,dc=example,dc=com
^D
 
 
^D 或者 按两次enter 表示退出交互式命令

本文采用 知识共享署名 4.0 国际许可协议(CC-BY 4.0)进行许可。转载请注明来源: https://snowfrs.com/2020/06/18/LDAP-command.html 欢迎对文中引用进行考证,欢迎指出任何不准确和模糊之处。