openldap常用命令

2019-08-15  本文已影响0人  yinkp001

1.添加用户(test):

添加linux系统用户到ldap:

 cat /etc/passwd |grep test > testpwd.in

/usr/share/migrationtools/migrate_passwd.pl testpwd.in >  testpwd.ldif

ldapadd -x -D "cn=root,dc=yinkp,dc=com" -w 123456 -f  testpwd.ldif

ldapsearch -x -b 'dc=yinkp,dc=com'

通过ldap配置文件添加用户:

vi ldapuser.ldif

# replace to your own domain name for "dc=***,dc=***" section

dn: uid=cent,ou=People,dc=yinkp,dc=com

objectClass: inetOrgPerson

objectClass: posixAccount

objectClass: shadowAccount

cn: Cent

sn: Linux

userPassword:123456

loginShell: /bin/bash

uidNumber: 1000

gidNumber: 1000

homeDirectory: /home/cent

dn: cn=cent,ou=Group,dc=yinkp,dc=com

objectClass: posixGroup

cn: Cent

gidNumber: 1000

memberUid: cent

ldapadd -x -D cn=root,dc=asiainfo,dc=com -W -f ldapuser.ldif

Enter LDAP Password:

adding new entry "cn=cent,ou=Group,dc=yinkp,dc=com"


2.删除用户(test)

ldapdelete -D "cn=root,dc=yinkp,dc=com" -w 123456  "uid=test,ou=People,dc=yinkp,dc=com"


3.修改用户密码(test)

ldappasswd -x -D "cn=root,dc=yinkp,dc=com" -W  "uid=test,ou=People,dc=yinkp,dc=com" -S


4.查询用户(test)

ldapsearch -x -b 'dc=yinkp,dc=com' |grep test

上一篇下一篇

猜你喜欢

热点阅读