dongwu4834 2015-04-23 17:25
浏览 191

使用ldap_mod_replace更新Active Directory中的用户字段

I am trying to update the mobile field for a user in Active Directory but I keep getting the following error. I have been trying to solve this for hours. It's probably something simple.

Warning: ldap_mod_replace(): Modify: Invalid syntax in /var/www/php_builders/admin/user_update/user_update_action.php on line 183

When I output the array, the mobile number shows up. its not empty.

ldap_set_option(NULL, LDAP_OPT_DEBUG_LEVEL, 7);
$adconn = ldap_connect("ldap://earth.example.com") or die("Couldn't connect to AD!");
$set = ldap_set_option($adconn, LDAP_OPT_PROTOCOL_VERSION, 3);
ldap_get_option($adconn, LDAP_OPT_PROTOCOL_VERSION, $value); 
$DN = 'CN=itcoopadmin,CN=Users,DC=example,DC=com';
$ldap_bind = ldap_bind($adconn, $DN, "**********");
$dn = trim($_POST['dn']);
$mobile = trim($_POST['mobile']);

if(!empty($mobile)) {
    $AD_mobile = AD_format($mobile);
    $DB_mobile = DB_format($mobile);
    $attributes['mobile'] = $AD_mobile;
} else {
    $DELETEattrs["mobile"] = array();
    $DELETEattrs = array();
}


$replace=ldap_mod_replace($adconn, $dn, $attributes); // Line 183, where the error is getting triggered

$disconnect = ldap_unbind($adconn);
  • 写回答

2条回答 默认 最新

  • dongwen2896 2015-04-24 04:07
    关注

    AFAIK the attribute has to be given as array. So I'd suggest that you try this:

    $attributes['mobile'] = array($AD_mobile);
    

    Hope that helps

    评论

报告相同问题?

悬赏问题

  • ¥17 pro*C预编译“闪回查询”报错SCN不能识别
  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向