dsce23640 2016-02-01 21:03
浏览 231
已采纳

使用samaccountname修改AD LDAP对象

I have a php script which works but I need to change it to use an AD account (samaccountname) instead of CN in this sample;

<?php

$base_dn="CN=Peter Parker,OU=Subcontainer,OU=Subcontainer,OU=Container,
DC=domain,DC=com";
$ldapconn = ldap_connect("host.domain.com") or die("Could not connect to LDAP server.");

if ($ldapconn)
{
    $ldapbind = ldap_bind($ldapconn, $ldapusername, $ldappassword);

    if ($ldapbind)
    {
        echo "LDAP bind successful ...";
    }
    else
    {
        echo "LDAP bind failed ...";
    }
}

$newinfo['ipphone']="555";
ldap_modify($ldapconn,$base_dn,$newinfo);
?>

The intention is to modify the ipphone object for users in AD, but I can't use CN because this input is not unique enough for the task. If the CN in the account's base DN is the descriptive name of the user, am I out of luck?

  • 写回答

1条回答 默认 最新

  • dpdhnd3577 2016-02-02 14:14
    关注

    You have to give ldap_modify the distinguished name (DN) of the account you want to change. There is no way around that.

    If you start out only knowing the sAMAccountName, then you can search the domain for the account first, then grab the distinguishedName attribute from the results.

    To search, use ldap_search using the filter "(sAMAccountName=username)"

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 宇视监控服务器无法登录
  • ¥15 PADS Logic 原理图
  • ¥15 PADS Logic 图标
  • ¥15 电脑和power bi环境都是英文如何将日期层次结构转换成英文
  • ¥20 气象站点数据求取中~
  • ¥15 如何获取APP内弹出的网址链接
  • ¥15 wifi 图标不见了 不知道怎么办 上不了网 变成小地球了
  • ¥50 STM32单片机传感器读取错误
  • ¥50 power BI 从Mysql服务器导入数据,但连接进去后显示表无数据
  • ¥15 (关键词-阻抗匹配,HFSS,RFID标签天线)