dtnbjjq51949 2019-08-14 11:45 采纳率: 0%
浏览 139

ldap_modify dos在函数中不起作用,抛出“Object class violation”错误

I created a php code that updates the user's email in AD. It works!
But I want to write code in functions. When I wrote the same code as the functions, ldap_modify throws "Object class violation" error.

Sorry about My bad ENG!

I checked all the variables, before function and in the function and everything seems ok. Or I'm blind and can't see a mistake.

This code works, and email is updated in AD

$entry["mail"] = 'foo@bar.com';
$result = ldap_modify($ldap->getLdap_connection(), $user_dn, $entry);
if ($result === false) {
   echo 'error';
}else{
   echo 'OK';
}

But when the code is written as a function, code throws "Object class violation" error.


function update_field($connection, $dn, $entry, $debug){
    $error = array();
    $result = NULL;

    if($connection === NULL){
       $error[] = 'LDAP connection is NULL'; 
    }

    if($dn === NULL){
       $error[] = 'User DN is NULL';
    }

    if($entry === NULL){
      $error[] = 'Field is NULL'; 
    }

    if($debug){ }        

    if(empty($error)){
        $result = ldap_modify($connection, $dn, $entry);        
        if($result === false) {
            $result = ldap_error($connection);
        }else{
            $result = 'OK';
        }
    }else{
        $result = $error;
    }
    return $result;
}

$entry["mail"] = 'foo@bar.com';
$update =  update_field($ldap->getLdap_connection(), $dn, $entry, 1); 
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 微信公众号自制会员卡没有收款渠道啊
    • ¥15 stable diffusion
    • ¥100 Jenkins自动化部署—悬赏100元
    • ¥15 关于#python#的问题:求帮写python代码
    • ¥20 MATLAB画图图形出现上下震荡的线条
    • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
    • ¥15 perl MISA分析p3_in脚本出错
    • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
    • ¥15 ubuntu虚拟机打包apk错误
    • ¥199 rust编程架构设计的方案 有偿