微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

如何连接到 Okta LDAP?

如何解决如何连接到 Okta LDAP?

所以,我有一个设置了 Okta 的 LDAP 目录。我无法使用 PHP 连接到它。这是我的代码

$domain = 'phishingBoxdecember15thaccount.ldap.okta.com';
$username = 'USERNAME';
$password = 'PASSWORD';
$ldapconfig['host'] = '44.234.52.17';  // I got this by pinging the domain. I guess that's correct?
$ldapconfig['port'] = 636;
$ldapconfig['basedn'] = 'dc=phishingBoxdecember15thaccount,dc=okta,dc=com';

$ds=ldap_connect($ldapconfig['host'],$ldapconfig['port']);

ldap_set_option($ds,LDAP_OPT_PROTOCOL_VERSION,3);
ldap_set_option($ds,LDAP_OPT_REFERRALS,0);

$dn="ou=users,".$ldapconfig['basedn'];
$bind=ldap_bind($ds,$username .'@' .$domain,$password);
print_r($bind);
$isITuser = ldap_search($bind,$dn,'(&(objectClass=User)(sAMAccountName=' . $username. '))');
if ($isITuser) {
    echo("Login correct");
} else {
    echo("Login incorrect");
}

然而这永远行不通。总是得到“登录不正确”,我确定我使用的是正确的密码(虽然,我不确定用户名部分 - 我只是使用我输入的用户名登录到我的 Okta 管理员帐户,我假设这是正确的?)。

您对我如何使用 PHP 连接到 Okta LDAP 有任何想法/提示吗?

解决方法

您需要的设置在文档 here 中。对我来说跳出来的是主机应该是 .ldap.okta.com 的形式,就像你在域变量中所拥有的那样。

我认为您的搜索需要调整为:ldap_search($bind,$dn,'(&(objectClass=inetOrgPerson)(uid=' . $username. '))'); 但这不会停止您的登录。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。