博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

ldap命令行操作

Posted on 2011-08-10 18:28  bw_0927  阅读(1970)  评论(0)    收藏  举报

以下纯属个人理解:

ldapadd时,提示说:ldap_bind: Invalid credentials (49)

其实不一定就是配置rootpw后面有空格的原因,是对ldapadd操作中的-D参数的误解。

sldapd.conf中的:

suffix          "dc=localhost,dc=localdomain"  //我的理解,这才是DIT树中的根目录

rootdn        "cn=Manager,dc=localhost,dc=localdomain"   //这相当于对上面这颗树拥有绝对管理权限的超级用户名

                             //这条DN并不会出现在真实的目录树中 

再来看ldapadd操作中的-D参数:

ldapadd -x -D "cn=Manager,dc=localhost,dc=localdomain" -W -f example.ldif   

-x     Use simple authentication instead of SASL.

-D binddn
              Use  the  Distinguished  Name binddn to bind to the LDAP directory.  For SASL
              binds, the server is expected to ignore this value(相当于用"cn=Manager,dc=localhost,dc=localdomain"这个超级账户对树"cn=Manager,dc=localhost,dc=localdomain"的add操作)
-W   使用slapd.conf中rootpw的密码
example.ldif文件的内容:
  1 dn: cn=Barbara Jensen,dc=localhost,dc=localdomain
  2 objectClass: person
  3 cn: Barbara Jensen
  4 cn: Babs Jensen
  5 sn: Jensen
ldapdelete操作同理:
ldapdelete -x -W -D "cn=Manager,dc=localhost,dc=localdomain" "cn=Barbara Jensen,dc=localhost,dc=localdomain"    //以-D指定的超级用户删除目录条目"cn=Barbara Jensen,dc=localhost,dc=localdomain"