douyun3799 2012-08-23 17:06
浏览 32
已采纳

如何使用授权帐户重新绑定到LDAP?

I am working on a project for a university. The University requires that all use login/information be stored in LDAP and retrieved via PHP. Normally I would just bind the LDAP connection with the credentials the user entered (so the individual user's username and password), however now I am required to authenticate their usernmae/password with LDAP, and then re-bind the connection with an "authorized account" username and password supplied by the department, and then perform the LDAP search from the authenticated account.

Basically I need to use the user's login/password just to ensure they exist in LDAP. If they are, then we must switch to a different account username/password to perform the LDAP search fro the user's information.

How would I do this? I have no idea how to re-bind in this manner but still perform the proper search on the user.

EDIT: is rebinding an LDAP account as simple as including a 2nd bind statement after the first? ex;

if (!($bind=@ldap_bind($connect, "uid=".$username.",ou=*****,dc=***,dc=edu", "$password")))
{
    ldap_close($connect);
    echo "there was an error binding your LDAP account.";
}
else // else we have binded to the ldap connection as the user, we must re-bind as the authorized account
{
    if (!($bind=@ldap_bind($connect, "uid=".$authUN.",ou=******,dc=***,dc=edu", "$authPW")))
    {
            ldap_close($connect);
            echo "There was a problem binding to the authorized account.";
    }
    else // now we have binded with the authenticated account
    {
        echo "success!";
    }
}    

..and then I would just perform the search normally via ldap_search()?

  • 写回答

3条回答 默认 最新

  • duanhuan6857 2012-08-23 20:06
    关注
    • There is no such thing as 're-bind'. There is only BIND
    • A connection begins with an anonymous authentication state
    • Each BIND request resets the connection state to an anonymous state
    • Each successful BIND sets the connection state to the authorization state associated with the authentication ID
    • A failed BIND request results in the connection retaining an anonymous state

    The semantics of BIND are described fully in RFC4513.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥50 导入文件到网吧的电脑并且在重启之后不会被恢复
  • ¥15 (希望可以解决问题)ma和mb文件无法正常打开,打开后是空白,但是有正常内存占用,但可以在打开Maya应用程序后打开场景ma和mb格式。
  • ¥15 绘制多分类任务的roc曲线时只画出了一类的roc,其它的auc显示为nan
  • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝
  • ¥20 腾讯企业邮箱邮件可以恢复么
  • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?
  • ¥15 错误 LNK2001 无法解析的外部符号
  • ¥50 安装pyaudiokits失败
  • ¥15 计组这些题应该咋做呀
  • ¥60 更换迈创SOL6M4AE卡的时候,驱动要重新装才能使用,怎么解决?