免费注册 查看新帖 |

Chinaunix

广告
  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 8104 | 回复: 3
打印 上一主题 下一主题

[ldap] LDAP: error code 64 - value of naming attribute 'cn' is not present in entry [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2006-02-18 11:54 |只看该作者 |倒序浏览
求救!!!!!!!!!!!!!!!!!!!1
一下是我的slapd.conf
#
# See slapd.conf(5) for details on configuration options.
# This file should NOT be world readable.
#
ucdata-path        d:/openldap/ucdata
include                d:/openldap/etc/schema/core.schema
include                d:/openldap/etc/schema/java.schema
include                d:/openldap/etc/schema/corba.schema
include                d:/openldap/etc/schema/cosine.schema
include                d:/openldap/etc/schema/dyngroup.schema
include                d:/openldap/etc/schema/inetorgperson.schema
include                d:/openldap/etc/schema/misc.schema
include                d:/openldap/etc/schema/nis.schema
include                d:/openldap/etc/schema/openldap.schema
# Define global ACLs to disable default read access.

# Do not enable referrals until AFTER you have a working directory
# service AND an understanding of referrals.
#referral        ldap://root.openldap.org

pidfile                d:/openldap/var/run/slapd.pid
argsfile        d:/openldap/var/run/slapd.args

# Load dynamic backend modules:
# modulepath        d:/openldap/libexec/openldap
# moduleload        back_bdb.la
# moduleload        back_ldap.la
# moduleload        back_ldbm.la
# moduleload        back_passwd.la
# moduleload        back_shell.la

# Sample security restrictions
#        Require integrity protection (prevent hijacking)
#        Require 112-bit (3DES or better) encryption for updates
#        Require 63-bit encryption for simple bind
# security ssf=1 update_ssf=112 simple_bind=64

# Sample access control policy:
#        Root DSE: allow anyone to read it
#        Subschema (sub)entry DSE: allow anyone to read it
#        Other DSEs:
#                Allow self write access
#                Allow authenticated users read access
#                Allow anonymous users to authenticate
#        Directives needed to implement policy:
# access to dn.base="" by * read
# access to dn.base="cn=Subschema" by * read
# access to *
#        by self write
#        by users read
#        by anonymous auth
#
# if no access controls are present, the default policy
# allows anyone and everyone to read anything but restricts
# updates to rootdn.  (e.g., "access to * by * read"
#
# rootdn can always read and write EVERYTHING!

#######################################################################
# BDB database definitions
#######################################################################

database        bdb
suffix                "dc=my-domain,dc=com"
rootdn                "cn=Manager,dc=my-domain,dc=com"
# Cleartext passwords, especially for the rootdn, should
# be avoid.  See slappasswd( and slapd.conf(5) for details.
# Use of strong authentication encouraged.
rootpw        secret
# The database directory MUST exist prior to running slapd AND
# should only be accessible by the slapd and slap tools.
# Mode 700 recommended.
directory        d:/openldap/var/openldap-data
# Indices to maintain
index        objectClass        eq
/////////////////////////////////////////////////
以下是lizongbo.ldif
dn:dc=my-domain,dc=com
objectclass:dcObject
objectclassrganization
o:companyinfo
dc:my-domain
///////////////////////////////
以下是我的java代码
/*
* 创建日期 2006-2-16
*
* TODO 要更改此生成的文件的模板,请转至
* 窗口 - 首选项 - Java - 代码样式 - 代码模板
*/

/**
* @author Administrator
*
* TODO 要更改此生成的类型注释的模板,请转至
* 窗口 - 首选项 - Java - 代码样式 - 代码模板
*/
import java.util.*;
import javax.naming.Context;
import javax.naming.NamingException;
import javax.naming.directory.DirContext;
import javax.naming.directory.InitialDirContext;


public class LDAPTest {
  public LDAPTest() {
  }


  public static void main(String[] args) {
    LDAPTest LDAPTest1 = new LDAPTest();
    String root = "dc=my-domain,dc=com"; //root


    Hashtable env = new Hashtable();
    env.put(Context.INITIAL_CONTEXT_FACTORY,
"com.sun.jndi.ldap.LdapCtxFactory";

    env.put(Context.PROVIDER_URL, "ldap://192.168.28.253/" + root);
    env.put(Context.SECURITY_AUTHENTICATION, "simple";

    env.put(Context.SECURITY_PRINCIPAL,
"cn=Manager,dc=my-domain,dc=com";

    env.put(Context.SECURITY_CREDENTIALS, "secret";
    System.out.print("################################";
    DirContext ctx = null;
    try {
      ctx = new InitialDirContext(env);
      Person p = new Person("mewilcox","Mark","Wilcox","ou=Accounting","mewilcox@siroe.com";
     ctx.bind("cn=mewilcox,dc=my-domain,dc=com",p);
      System.out.println("认证成功";
    }
    catch (javax.naming.AuthenticationException e) {
      e.printStackTrace();
      System.out.println("认证失败-------------------"+e.getMessage());
      e.printStackTrace();
    }
    catch (Exception e) {
      System.out.println("认证出错==================="+e.getMessage());
      e.printStackTrace();
    }


    if (ctx != null) {
      try {
        ctx.close();
      }
      catch (NamingException e) {
        //ignore
      }
    }
    System.exit(0);
  }



}
////////////////////////////////////////////////////
现在我不知道为什么会报以下第二的错误
################################javax.naming.InvalidNameException: cn=mewilcox,dc=my-domain,dc=com: [LDAP: error code 64 - value of naming attribute 'cn' is not present in entry]; remaining name 'cn=mewilcox,dc=my-domain,dc=com'
认证出错===================cn=mewilcox,dc=my-domain,dc=com: [LDAP: error code 64 - value of naming attribute 'cn' is not present in entry]
        at com.sun.jndi.ldap.LdapCtx.processReturnCode(Unknown Source)
        at com.sun.jndi.ldap.LdapCtx.processReturnCode(Unknown Source)
        at com.sun.jndi.ldap.LdapCtx.c_bind(Unknown Source)
        at com.sun.jndi.ldap.LdapCtx.c_bind(Unknown Source)
        at com.sun.jndi.toolkit.ctx.ComponentContext.p_bind(Unknown Source)
        at com.sun.jndi.toolkit.ctx.PartialCompositeContext.bind(Unknown Source)
        at com.sun.jndi.toolkit.ctx.PartialCompositeContext.bind(Unknown Source)
        at javax.naming.InitialContext.bind(Unknown Source)
        at LDAPTest.main(LDAPTest.java:47)
希望高手指点。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。

论坛徽章:
0
2 [报告]
发表于 2006-02-18 12:35 |只看该作者
"error code 64 - value of naming attribute 'cn' is not present"

cn不存在

论坛徽章:
0
3 [报告]
发表于 2006-02-18 13:47 |只看该作者
要怎么解决!!!!
我刚刚学这个谢谢

论坛徽章:
0
4 [报告]
发表于 2006-02-18 13:57 |只看该作者
能不能具体写一下谢谢!
在线等·
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP