ldap - php login failure using AD LDS -


I am trying to write a basic php script that connects my AD LDS example and authenticates a user , But I'm getting the login failure. The scripts are:

  & lt ;? Php included ("authenticate.php"); // Check whether the user is logging in or not (isset ($ _GET ['out'])) // // destroy the session session_unset (); $ _SESSION = Array (); Not set ($ _ session ['user'], $ _ session ['access']); session_destroy (); } // Check to see if the login form has been submitted if (isset ($ _ POST ['userLogin'])) {// Run information through authentication (if certify ($ _ POST ['userlogin' ], $ _ POST ['userpassword'])) {// authentication passed title ("location: success.php"); Die (); } Else {// authentication failed $ error = 1; }} // If the output error for the user echo (isset ($ error)) "Login failed: incorrect user name, password, or rights 
"; // Output logout success if (isset ($ _GET ['out'])) "logout successful" echo; ? & Gt; & Lt; Form action = "login.php" method = "post" & gt; User: & lt; Input type = "text" name = "userlogin" /> & Lt; Br / & gt; Password: & lt; Input type = "password" name = "user password" /> & Lt; Input type = "submit" name = "submit" value = "submit" /> & Lt; / Form & gt; The certification function is as follows: For ldap_dn and ldap_host, I have put the value for the specific example of Active Directory and the primary example of AD LDS server respectively.
  function authentication ($ user, $ password) {// Active Directory server $ ldap_host = "server"; // Active Directory DN $ ldap_dn = "he = mycompany, C = US"; // Connect to Active Directory $ ldap = ldap_connect ($ ldap_host); // Verify user and password if ($ bind = @ldap_bind ($ ldap, $ user, $ password)) {// valid echo "lift"; Warning ('legal'); & Lt; / Script & gt; Check out the presence in the "// groups $ filter =" (userPrincipalName = ". $ User."); $ Attr = array ("memberof"); $ result = ldap_search ($ ldap, $ ldap_dn, $ filter, $ attr) or exit ("unable to find LDAP server"); $ entries = ldap_get_entries ($ ldap, $ result); ldap_unbind ($ ldap); if ($ result) {$ _SESSION ['user'] = $ User; return true;} other {return false;}} Else {// invalid name or password return incorrect;} If ($ ldap) return is correct; second false return;}   

I still get a login failure. Do I Is setting up ldap host or ldap_dn incorrectly? If so, what values ​​should I set?

As far as I know ldap_bind hopefully the given username should be a DN and you are just providing a username. I doubt it works. .

When I'm LDAP-login, I always use an anonymous bind or a dedicated user account Would subject that bind dirt to get DN username name and I like to use the same DN I just retrieved bind each other with DN and password. It always works like a magic and as I can define for myself what type of feature I use to search for DN, which I can use to enter specific (unique) attributes .

I have created the basic concept to show

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -