Let’s say I have a server called examplesite.database.windows.net that has a database called Database. The username and password are [email protected] and password respectively.
I need to connect via “Active Directory – Password” authentication as per my company’s policy (I do not have privileges to change anything about the server, switching to alternative forms of authentication are also disallowed).
I would like to use PHP to connect to database and am currently trying out the LDAP php extension, but I could not find anything within the LDAP documentation that would allow me to specify the database property (“Database” in this example) to connect to. The account in question only has privileges for this database and not the entire server.
Can anyone point me in the right direction?
If LDAP does not enable the Database property to be specified, are there any alternatives within php that are suitable for Active Directory connections?
Some sample code I tried is below:
<?php
$ldap_dn = "uid=account,dc=example,dc=com";
$ldap_password = "password";
$ldap_con = ldap_connect("examplesite.database.windows.net") or die('Could not connect to LDAP server');
ldap_set_option($ldap_con, LDAP_OPT_PROTOCOL_VERSION, 3);
ldap_set_option($ldap_con, LDAP_OPT_REFERRALS, 0);
if ($ldap_con)
$ldap_bind = ldap_bind($ldap_con, $ldap_dn, $ldap_password);
if ($ldap_bind) {
echo "Bind Successful";
} else {
echo "Error";
}
?>