• <tfoot id='TDwoZ'></tfoot>

    <legend id='TDwoZ'><style id='TDwoZ'><dir id='TDwoZ'><q id='TDwoZ'></q></dir></style></legend>

    <i id='TDwoZ'><tr id='TDwoZ'><dt id='TDwoZ'><q id='TDwoZ'><span id='TDwoZ'><b id='TDwoZ'><form id='TDwoZ'><ins id='TDwoZ'></ins><ul id='TDwoZ'></ul><sub id='TDwoZ'></sub></form><legend id='TDwoZ'></legend><bdo id='TDwoZ'><pre id='TDwoZ'><center id='TDwoZ'></center></pre></bdo></b><th id='TDwoZ'></th></span></q></dt></tr></i><div id='TDwoZ'><tfoot id='TDwoZ'></tfoot><dl id='TDwoZ'><fieldset id='TDwoZ'></fieldset></dl></div>

    <small id='TDwoZ'></small><noframes id='TDwoZ'>

      <bdo id='TDwoZ'></bdo><ul id='TDwoZ'></ul>
      1. LDAP 问题,ldap_bind 无效的 dn 语法

        时间:2024-08-23

        <i id='GvwCZ'><tr id='GvwCZ'><dt id='GvwCZ'><q id='GvwCZ'><span id='GvwCZ'><b id='GvwCZ'><form id='GvwCZ'><ins id='GvwCZ'></ins><ul id='GvwCZ'></ul><sub id='GvwCZ'></sub></form><legend id='GvwCZ'></legend><bdo id='GvwCZ'><pre id='GvwCZ'><center id='GvwCZ'></center></pre></bdo></b><th id='GvwCZ'></th></span></q></dt></tr></i><div id='GvwCZ'><tfoot id='GvwCZ'></tfoot><dl id='GvwCZ'><fieldset id='GvwCZ'></fieldset></dl></div>
              <tbody id='GvwCZ'></tbody>
            <tfoot id='GvwCZ'></tfoot>

            <small id='GvwCZ'></small><noframes id='GvwCZ'>

            <legend id='GvwCZ'><style id='GvwCZ'><dir id='GvwCZ'><q id='GvwCZ'></q></dir></style></legend>

                  <bdo id='GvwCZ'></bdo><ul id='GvwCZ'></ul>
                • 本文介绍了LDAP 问题,ldap_bind 无效的 dn 语法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我知道我的错误会很简单,但我试图找到问题,但我没有看到它,也许你可以帮助我....

                  I know that my mistake is going to be something really simple but I have tried to find the problem and I do not see it, maybe you can help me....

                  我正在尝试使用 php 创建一个函数,以便能够连接到 LDAP 并找到所需的信息.

                  I am trying to create a function with php, so I can be able to connect to LDAP and find the desired information.

                  我的php代码如下:

                  $ldapconfig['host'] = "127.0.0.1";
                  $ldapconfig['port'] = NULL;
                  $ldapconfig['basedn'] = "dc=example,dc=com";
                  $ldapconfig['binddn'] = "user";
                  $ldapconfig['bindpw'] = "password";
                  
                  
                  function ldap_authenticate($user, $pass) {
                  global $ldapconfig;
                  ldap_set_option(NULL, LDAP_OPT_DEBUG_LEVEL, 7); 
                  if ($user != "" && $pass != "") {
                      $ds=ldap_connect($ldapconfig['host'],$ldapconfig['port']);
                      if(!ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3)) {
                          return NULL;
                      }
                      ldap_set_option($ds, LDAP_OPT_REFERRALS, 0);
                      ldap_bind( $ds, $ldapconfig['binddn'], $ldapconfig['bindpw']);
                      $r = ldap_search( $ds, $ldapconfig['basedn'], 'sAMAccountName=' . $user);
                      if ($r) {
                          $result = ldap_get_entries( $ds, $r);
                          if ($result[0]) {
                              if (ldap_bind( $ds, $result[0]['dn'], $pass) ) {
                                  return $result[0]['mail'][0];
                              }
                          }
                      }
                  }
                  return NULL;
                  

                  当我尝试运行代码时,它给了我以下错误:ldap_bind 第 xxxx 行的 DN 语法无效该行如下:

                  When I try to run the code it gives me the following mistake: ldap_bind invalid DN syntax on line xxxx and that line is the following:

                  ldap_bind( $ds, $ldapconfig['binddn'], $ldapconfig['bindpw']);
                  

                  推荐答案

                  如错误中所述,您的绑定 DN 格式错误.DN 代表对象的完整路径 - 所以在你的情况下应该是这样的(看起来你在 AD 上?)

                  As stated in the error, your bind DN is the wrong format. DN's represent the full path to the object - so in your case should be something like this (looks like you're on AD?)

                  "cn=username,ou=域用户,dc=example,dc=com"

                  "cn=username,ou=domain users,dc=example,dc=com"

                  根据您的 LDAP(Active Directory、OpenLDAP 等)的风格,您可能能够使用 uid(所以只是用户名")进行绑定,但最好假设您总是需要完整的 DN.

                  Depending on your flavor of LDAP (Active Directory, OpenLDAP etc), you might be able to use a uid (so just 'username') to bind, but it's best to assume that you always need the full DN.

                  您可以使用诸如 Apache Directory Studio 之类的 LDAP 工具来帮助构建查询并找出对象的DN 是.或者也有 ldp.exe(前提是它是 AD),但是 directory studio 更容易使用.

                  You can use an LDAP tool like Apache Directory Studio to help build queries and find out what object's DN's are. Or there's ldp.exe too (provided it's AD), but directory studio is easier to use.

                  这篇关于LDAP 问题,ldap_bind 无效的 dn 语法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:PHP ldap_add 函数以转义 DN 语法中的 ldap 特殊字符 下一篇:致命错误:在 ubuntu 中调用未定义函数 ldap_connect()

                  相关文章

                    <tfoot id='l34bh'></tfoot>

                  1. <legend id='l34bh'><style id='l34bh'><dir id='l34bh'><q id='l34bh'></q></dir></style></legend>
                    1. <i id='l34bh'><tr id='l34bh'><dt id='l34bh'><q id='l34bh'><span id='l34bh'><b id='l34bh'><form id='l34bh'><ins id='l34bh'></ins><ul id='l34bh'></ul><sub id='l34bh'></sub></form><legend id='l34bh'></legend><bdo id='l34bh'><pre id='l34bh'><center id='l34bh'></center></pre></bdo></b><th id='l34bh'></th></span></q></dt></tr></i><div id='l34bh'><tfoot id='l34bh'></tfoot><dl id='l34bh'><fieldset id='l34bh'></fieldset></dl></div>
                      • <bdo id='l34bh'></bdo><ul id='l34bh'></ul>

                      <small id='l34bh'></small><noframes id='l34bh'>