Windows XP Windows 7 Windows 2003 Windows Vista Windows教程綜合 Linux 系統教程
Windows 10 Windows 8 Windows 2008 Windows NT Windows Server 電腦軟件教程
 Windows教程網 >> Windows教程綜合 >> 關於windows >> windows下安裝ldap及測試基礎教程

windows下安裝ldap及測試基礎教程

日期:2017/2/7 14:16:24      編輯:關於windows
 

下載openldap2.2.29.rar,並一路next下去。

然後根據網上配置slapd.conf:

在include ./schema/core.schema這行下加入

include ./schema/cosine.schema
include ./schema/inetorgperson.schema
include ./schema/nis.schema
include ./schema/misc.schema

然後用php測試,測試代碼是:

<?php
//ldap服務地址
$ldap_host = "ldap://127.0.0.1";
//ldap服務占用端口
$ldap_port = 389;
//鏈接ldap服務器
$ldap_conn = ldap_connect($ldap_host, $ldap_port) or die("Can not connect LDAP server.");

//管理員登錄名
$rootdn = 'cn=Manager,dc=my-domain,dc=com';
//密碼
$rootpw = 'secret';
//綁定用戶
ldap_bind($ldap_conn, $rootdn, $rootpw) ;//or die("Can not binding to LDAP server.");

var_dump($ldap_conn);

?>

但提示:

Warning: ldap_bind() [function.ldap-bind]: Unable to bind to server: Protocol error in D:\virtual\test.php on line 14
resource(2) of type (ldap link)

於是又在網上找到解決辦法:

在slapd.conf 最後加一句:allow bind_v2

原因(據openldap官網):

OpenLDAP Software does not support LDAPv2 (now historic). OpenLDAP 2.x's slapd(8) can be configured to accept a version 2 LDAP Bind request, but expects requesting version 2 to speak a restricted, non-standard variant for LDAPv3 (basically LDAPv3 syntaxes and semantics in LDAPv2 PDUs). To enable this, place the following in your slapd.conf(5) file.

照著加入了後重啟OpenLDAP Directory Service後,就正常了。
 

Copyright © Windows教程網 All Rights Reserved