1
如何将PHP连接到活动目录并进行用户身份验证?我已经使用WAMP在本地尝试了LDAP,但到目前为止还没有成功,可能做错了?使用Microsoft Azure活动目录进行PHP用户身份验证
我尝试这样做:
$link = ldap_connect('domain.com'); // Your domain or domain server
if(! $link)
{
// Could not connect to server - handle error appropriately
}
ldap_set_option($link, LDAP_OPT_PROTOCOL_VERSION, 3); // Recommended for AD
// Now try to authenticate with credentials provided by user
if (! ldap_bind($link, '[email protected]', 'SomeSecret'))
{
// Invalid credentials! Handle error appropriately
}
// Bind was successful - continue
改变域名为我的Active Directory域 “davidecuriosidade.onmicrosoft.com”,但正如我所说的没有成功。我的活动目录是否有配置?
我该如何修改?类似$ user = sAMAccountName = myuser,ou = GroupAllowed,dc = domain,dc = com? – DavideBar
你必须连接字符串。我的建议是: – Danoweb
$ bind ='sAMAccountname ='。 $用户名。 ',ou ='。 $组。 'DC =域,DC = COM'; 或者你也可以使用如下的解决方案: $ bind ='sAMAccountname ='。 $的用户名; $ bind。=',ou ='。 $组; $ bind。=',dc = domain,dc = com'; 然后你打电话会变成: ldap_bind($ link,$ bind,'SomeSecret') – Danoweb