简体   繁体   English

PHP LDAPS提供的参数不是有效的ldap链接资源

[英]PHP LDAPS supplied argument is not a valid ldap link resource

I am trying to connect to a remote LDAP server from a local Ubuntu VM Box on my Windows machine. 我试图从我的Windows机器上的本地Ubuntu VM Box连接到远程LDAP服务器。 The PHP code is: PHP代码是:

$ldap = ldap_connect("ldaps://11.22.33.44",636);
ldap_set_option ($ldap, LDAP_OPT_REFERRALS, 0);
ldap_set_option($ldap, LDAP_OPT_PROTOCOL_VERSION, 3);
$username = "domain\usr";
$password = "blah";
$ds = ldap_bind($ldap, $username, $password );
if( $ds ){
    echo "logged in!";
}
else{
    echo "failed to log in!";
    exit;
}

When running this I get the 'logged in!' 运行时我得到'登录!' message, so I'm assuming that the connection is working. 消息,所以我假设连接正常。 However, when I run this PHP code afterwards: 但是,当我之后运行此PHP代码时:

$sr = ldap_search($ds, "OU=User Accounts,DC=Domain1,DC=foobar,DC=Local", "(|(sn=*))");

I get this error: 我收到此错误:

Warning: ldap_search(): supplied argument is not a valid ldap link resource in /usr/share/nginx/www/ldap_test.php on line 37 警告:ldap_search():提供的参数不是第37行/usr/share/nginx/www/ldap_test.php中的有效ldap链接资源

(which refers to the line that contians the ldap_search command. This doesn't make sense if the connection is successful and a link resource is created - any ideas? (它指的是包含ldap_search命令的行。如果连接成功并且创建了链接资源,这没有意义 - 任何想法?

ldap_bind will return true or false . ldap_bind将返回truefalse You need to pass the result of ldap_connect to ldap_search instead - which is $ldap in your example. 您需要将ldap_connect的结果传递给ldap_search - 在您的示例中为$ldap

$sr = ldap_search($ldap, "OU=User Accounts,DC=Domain1,DC=foobar,DC=Local", "(|(sn=*))");

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 提供的参数不是php codeigniter中的有效图像资源 - supplied argument is not a valid Image resource in php codeigniter PHP / MySQL-mysql_error():提供的参数不是有效的MySQL-Link资源 - PHP / MySQL - mysql_error(): supplied argument is not a valid MySQL-Link resource mysql_query():提供的参数不是有效的 MySQL-Link 资源 - mysql_query(): supplied argument is not a valid MySQL-Link resource mysql_close():提供的参数不是有效的MySQL-Link资源 - mysql_close(): supplied argument is not a valid MySQL-Link resource mysql_error():提供的参数不是有效的MySQL-Link资源 - mysql_error(): supplied argument is not a valid MySQL-Link resource IE 中的 PHP 问题“提供的参数不是有效的 stream 资源” - PHP problem in IE “supplied argument is not a valid stream resource” PHP错误:“提供的参数不是其中的有效MySQL结果资源” - PHP error: “supplied argument is not a valid MySQL result resource in” PHP FreeTDS MSSQL Connection中的错误,提供的参数不是有效的链接 - Error in PHP FreeTDS MSSQL Connection, supplied argument is not a valid link PHP foreach提供的参数无效 - php foreach supplied argument not valid 提供的ImageSX和ImageSY参数不是有效的图像资源 - ImageSX and ImageSY supplied argument is not a valid Image resource
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM