7

OpenLDAP 2.4.32 および PHP 5.4.6 で ldap_modify を使用すると、不十分なアクセス エラーが発生します。

エラーが発生している php 関数は次のようになります。

function set_user($dn, $password, $data)
{
  /* This function sets the users infomation */

  // Get Configuration Items
  $ldapServer = $this->config->item('ldapServer');
  $ldapDCRoot = $this->config->item('ldapDCRoot');


  // Connect to LDAP
  $ldapConnection = ldap_connect($ldapServer);

  if($ldapConnection)
  {
    $r = ldap_bind($ldapConnection, $dn, $password);
    if ($r)
    {
      // Bind completed successfully
      $r = ldap_modify($ldapConnection, $dn, $data);
      return True;
    }
    die("Unsuccessful Bind");
  }
  die("Can't connect to LDAP");
}

$dn は、情報とパスワードを変更しようとしているユーザーの完全な DN です。$data は更新中の値です。現在のデータには、変更する電話番号が含まれているだけです $data['mobile'] = "newPhoneNumber". データが実際に書き込まれることはないという事実を除いて、これはすべて機能しているように見えます。

openldap ファイルを以下に示します。ACL に書き込み可能であることが示されていることがわかります。

include     /etc/openldap/schema/corba.schema
include     /etc/openldap/schema/core.schema
include     /etc/openldap/schema/cosine.schema
include     /etc/openldap/schema/duaconf.schema
include     /etc/openldap/schema/dyngroup.schema
include     /etc/openldap/schema/inetorgperson.schema
include     /etc/openldap/schema/java.schema
include     /etc/openldap/schema/misc.schema
include     /etc/openldap/schema/nis.schema
include     /etc/openldap/schema/openldap.schema
include     /etc/openldap/schema/ppolicy.schema
include     /etc/openldap/schema/collective.schema

allow bind_v2

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

TLSCertificateFile /etc/pki/tls/certs/slapd.pem
TLSCertificateKeyFile /etc/pki/tls/certs/slapd.pem

access to *
    by self write
    by users read
    by anonymous auth


database    bdb
suffix      "dc=example,dc=com"
checkpoint  1024 15
rootdn      "cn=manager,dc=example,dc=com"
rootpw          REDACTED

directory   /var/lib/ldap

index objectClass                       eq,pres
index ou,cn,mail,surname,givenname      eq,pres,sub
index uidNumber,gidNumber,loginShell    eq,pres
index uid,memberUid                     eq,pres,sub
index nisMapName,nisMapEntry            eq,pres,sub

問題は、なぜ PHP が値を更新できず、代わりに不十分なアクセス エラーが発生するのかということです。

4

2 に答える 2

2

問題をデバッグするには、コマンド ライン ツールldapmodifyを使用して同じリクエストを行うことをお勧めします。システムにインストールする必要がある場合があります (Redhat openldap-clients、Debian slapd)。

LDAP ユーティリティ

デバッグ レベル-dを設定することで、呼び出しが不十分なアクセス エラーを返す理由について、php ライブラリが提供するものよりも多くの情報を得ることができます。

ldapmodifyでこれを行う必要はありませんでしたが、 ldapsearchでこれを使用して大きな成功を収めました。ldapmodify --helpそのため、検索や使用方法を理解するのに時間がかかる場合があります。

コマンドは次のようになると思います。

ldapmodify -d 7 -h ldap.server.com -D bind_dn -w bind_password -f /tmp/entrymods
于 2016-04-21T18:03:59.893 に答える