免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
12
最近访问板块 发新帖
楼主: hxlxsj
打印 上一主题 下一主题

[ldap] ldap连接本地服务器问题 [复制链接]

论坛徽章:
0
11 [报告]
发表于 2005-02-25 09:04 |显示全部楼层

ldap连接本地服务器问题

我在c:\openldap\var\openld-data\下面建有一文件xsj.ldif,其内容是:
dn: dc=myadmin.com,o=myadmin
dc: myadmin.com
objectClass: dcObject
objectClass: organization
o: myadmin

dn: uid=abcd, dc=myadmin.com,o=myadmin
sn: abcd
userPassword:: e2NyeXB0fXNtOEtMcGxrbE90bmM=
loginShell: /bin/sh
gidNumber: 99
uidNumber: 99
mail: abcd@myadmin.com
objectClass: person
objectClass: inetorgperson
objectClass: dcObject
objectClass: country
objectClass: posixAccount
uid: abcd
c: China
isProxy: 1
cn: abcd
homeDirectory: /home/ftp
dc: myadmin.com

dn: uid=test, dc=myadmin.com,o=myadmin
sn: test
userPassword:: e2NyeXB0fXNtYlBlRFVDZXd5dms=
mail: test@myadmin.com
objectClass: person
objectClass: inetorgperson
objectClass: dcObject
objectClass: country
uid: test
c: China
cn: test
isProxy: 1
dc: myadmin.com
.......
我在php文件中写入:
$ds=ldap_connect("localhost","389";
$r = ldap_bind($ds,"cn=abcd,o=myadmin","secret";
报告如下:
ldap_bind(): Unable to bind to server: Protocol error in  ...
我在slapd.conf中是这样配置的:
suffix "dc=myadmin.com"
rootdn "uid=abcd,o=myadmin,dc=myadmin.com"
rootpw secret
directory        C:/openldap/var/openldap-data
index objectClass eq
我按照leave教我的来绑定:
$ldaprdn = "uid=,o=myadmin,dc=myadmin.com";
$ldappass = "secret";
$ldapbind = ldap_bind($ds, $ldaprdn, $ldappass);
报告:
Unable to bind to server: Can't contact LDAP server in ......
...
...
...
...

论坛徽章:
0
12 [报告]
发表于 2005-02-25 15:56 |显示全部楼层

ldap连接本地服务器问题

在php文件中写入:
$ds=ldap_connect("localhost","389";
$r = ldap_bind($ds,"cn=abcd,o=myadmin","secret";
错误报告如下:
ldap_bind(): Unable to bind to server: Protocol error in  ...

难道是密码(secret)有误?
ldif文件如何转为openldap的数据库?
因为我没有linux,谁能告诉我在win2000下openldap的数据库是如何创建的。以及相关文件的设置和位置在哪里?

论坛徽章:
0
13 [报告]
发表于 2005-02-28 08:42 |显示全部楼层

ldap连接本地服务器问题

谢谢leave
我用您介绍的两种方法均试过,但仍有错误报告:
Unable to bind to server: Invalid credentials in ......

论坛徽章:
0
14 [报告]
发表于 2005-02-28 11:52 |显示全部楼层

ldap连接本地服务器问题

谢谢NetSnake
我现在是在win2000下能连接openldap服务器,只是不能绑定,请指教!
我的问题在已经一个星期了,请各位高手帮帮忙!

论坛徽章:
0
15 [报告]
发表于 2005-02-28 13:06 |显示全部楼层

ldap连接本地服务器问题

我在php ldap_bind之前加上下面的一段:
if (ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3)) {
echo "Using LDAPv3"."<br />;";
} else {
echo "Failed to set protocol version to 3"."<br />;";
}
能够通过,显示"Using LDAPv3".
但仍是错误信息:Unable to bind to server: Invalid credentials in...


我在slapd.conf中加入allow bind_v2后,openldap服务器起不来,显示为:
.......
bdb_db_init:Initializing BDB database
.\slapd.conf:line 80:allow line must appear prior to database definitions
.\slapd.conf:line 80:unknown feature bind_v3 in "allow <features>;" line
slapd shutdown:freeing system resources.

请高手们指点。谢谢
slapd stopped.
connections_destroy:nothing to destroy.

论坛徽章:
0
16 [报告]
发表于 2005-03-01 08:33 |显示全部楼层

ldap连接本地服务器问题

谢谢,我的slapd.conf如下:
#
# See slapd.conf(5) for details on configuration options.
# This file should NOT be world readable.
#
ucdata-path        C:/openldap/ucdata
include                C:/openldap/etc/schema/core.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                C:/openldap/var/run/slapd.pid
argsfile        C:/openldap/var/run/slapd.args

# Load dynamic backend modules:
# modulepath        C:/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        C:/openldap/var/openldap-data
#
# Indices to maintain
#
index objectClass eq
#
#index cn,sn,uid
#index default none

allow bind_v2

论坛徽章:
0
17 [报告]
发表于 2005-03-02 09:01 |显示全部楼层

ldap连接本地服务器问题

我的slapd.conf文件内容改成:
ucdata-path C:/openldap/ucdata
include C:/openldap/etc/schema/core.schema
pidfile C:/openldap/var/run/slapd.pid
argsfile C:/openldap/var/run/slapd.args
allow bind_v2
database bdb
suffix "dc=test.com"
rootdn "uid=abcd,o=test,dc=test.com"
rootpw secret
directory        C:/openldap/var/openldap-data
index objectClass eq

我测试用的php文件内容为:
<?php
$ldap['host'] = "localhost";
$ldap['port'] = 389;
$ldap['dn']   = "uid=abcd,dc=test.com";
$ldap['base'] = "";

// connecting to ldap
echo "start LDAP <br>;";
echo "连接中 ...";
$ds=ldap_connect($ldap['host'],$ldap['port']);
echo "连上 ".$ds."<br>;";

if ($ds){
        $r = ldap_bind($ds,"dc=test.com","secret";
}else{
        echo "fail";
}
?>;


我的c:\openldap\var\openldap-data\test.ldif文件内容为:
dn: uid=abcd,dc=test.com,o=test
dc: test.com
objectClass: dcObject
objectClass: organization
o: test

但经过测试,错误显示还为:

start LDAP
连接中 ...连上 Resource id #2

Warning: ldap_bind(): Unable to bind to server: Invalid credentials in ......
表明能连上服务器,但不能绑定。

论坛徽章:
0
18 [报告]
发表于 2005-03-03 08:54 |显示全部楼层

ldap连接本地服务器问题

starxing您好:
我按照您的意思照办但问题依照
Warning: ldap_bind(): Unable to bind to server: Invalid credentials in .....

论坛徽章:
0
19 [报告]
发表于 2005-03-03 11:31 |显示全部楼层

ldap连接本地服务器问题

我完全按照您的意思完成了修改,经测试错误还是如下:
Could not bind LDAP server.
运行ldapsearch -x -b "dc=test.com"
显示:ldap_bind:Can't contact LDAP server (-1)
同时ldap服务启不来,显示:
....
c:/openldap/etc/schema/core.schema:line 77uplicate attributeType:"2.5.4.2"
slapd shutdown:freeing system resources.
slapd staopped.
connections_destroy:nothing to destroy.

论坛徽章:
0
20 [报告]
发表于 2005-03-04 08:45 |显示全部楼层

ldap连接本地服务器问题

starxing:
我已经把我的slapd.conf,xsj.ldif,test.php以及openldap服务启动情况发给您了。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

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

清除 Cookies - ChinaUnix - Archiver - WAP - TOP