使用Adldap php类,但在查找用户所属的组时出错
以前从未使用过这个类,因此我不确定它为什么会给我这个错误,非常感谢您的帮助。当实例化使用Adldap php类,但在查找用户所属的组时出错,php,authentication,class,ldap,Php,Authentication,Class,Ldap,以前从未使用过这个类,因此我不确定它为什么会给我这个错误,非常感谢您的帮助。当实例化adLDAP类时,您将实例对象存储在$adLDAP中: $result=$ldap->user_groups($username); $adldap = new adLDAP(); 但是,稍后,您将尝试使用$ldap: $result=$ldap->user_groups($username); $adldap = new adLDAP(); $ldap变量不存在——因此需要注意 由于它不
adLDAP
类时,您将实例对象存储在$adLDAP
中:
$result=$ldap->user_groups($username);
$adldap = new adLDAP();
但是,稍后,您将尝试使用
$ldap
:
$result=$ldap->user_groups($username);
$adldap = new adLDAP();
$ldap
变量不存在——因此需要注意
由于它不存在,PHP认为它是
null
而null
不是一个对象——这意味着您无法对其调用方法——这解释了致命错误
我想你应该换一行:
$result=$ldap->user_groups($username);
通过这个:
$result=$ldap->user_groups($username);
注意$adldap
而不是$ldap
,以使用adldap
类的实例,而不是不存在的变量