How Can I Connect Php Script To Active Directory With XAMPP Server - Programming - Nairaland
Nairaland Forum › Science/Technology › Programming › How Can I Connect Php Script To Active Directory With XAMPP Server (2248 Views)
| How Can I Connect Php Script To Active Directory With XAMPP Server by hundu(op): 3:27pm On Mar 12, 2015 |
Please any help... i always get this error anytime i try. Fatal error: Call to undefined function ldap_connect() in C:\xampp\htdocs\Active_directory\index.php on line 9 <?php if(isset($_POST['username']) && isset($_POST['password'])){ $adServer = "ldap://trustfundpensions.net"; $ldap = ldap_connect($adServer); $username = $_POST['username']; $password = $_POST['password']; $ldaprdn = 'mydomain' . "\\" . $username; ldap_set_option($ldap, LDAP_OPT_PROTOCOL_VERSION, 3); ldap_set_option($ldap, LDAP_OPT_REFERRALS, 0); $bind = @ldap_bind($ldap, $ldaprdn, $password); if ($bind) { $filter="(sAMAccountName=$username)"; $result = ldap_search($ldap,"dc=MYDOMAIN,dc=COM",$filter); ldap_sort($ldap,$result,"sn" ;$info = ldap_get_entries($ldap, $result); for ($i=0; $i<$info["count"]; $i++) { if($info['count'] > 1) break; echo "<p>You are accessing <strong> ". $info[$i]["sn"][0] .", " . $info[$i]["givenname"][0] ."</strong><br /> (" . $info[$i]["samaccountname"][0] ." </p>\n";echo '<pre>'; var_dump($info); echo '</pre>'; $userDn = $info[$i]["distinguishedname"][0]; } @ldap_close($ldap); } else { $msg = "Invalid email address / password"; echo $msg; } }else{ ?> <form action="#" method="POST"> <label for="username">Username: </label><input id="username" type="text" name="username" /> <label for="password">Password: </label><input id="password" type="password" name="password" /> <input type="submit" name="submit" value="Submit" /> </form> <?php } ?> |
| Re: How Can I Connect Php Script To Active Directory With XAMPP Server by FRInteractives: 6:33pm On Mar 12, 2015 |
Did you include or require the file where you declared the ldap_connect(). Function? You must include that file to this page using the require_once() So that php can find that file. |
| Re: How Can I Connect Php Script To Active Directory With XAMPP Server by hundu(op): 8:37am On Mar 13, 2015 |
I'm connecting from the same page. Below is my connection. Thanks. $adServer = "ldap://trustfundpensions.net"; $ldap = ldap_connect($adServer); $username = $_POST['username']; $password = $_POST['password']; |
| Re: How Can I Connect Php Script To Active Directory With XAMPP Server by FRInteractives: 9:29am On Mar 13, 2015 |
So does the idap_connect() function exists? You have to create the function first before you use it if it doesn't exists, if the function exists in a remote file also include that file in to every page you will use the function hundu: |
| Re: How Can I Connect Php Script To Active Directory With XAMPP Server by hundu(op): 12:58pm On Mar 17, 2015 |
How can i create the ldap_connect() function. Sample code please. |
| Re: How Can I Connect Php Script To Active Directory With XAMPP Server by FRInteractives: 4:29pm On Mar 17, 2015 |
This is the php syntax to create any function: <?php function idap_connect() { //function codes goes here } ?> hundu: |
| Re: How Can I Connect Php Script To Active Directory With XAMPP Server by hundu(op): 10:19am On Mar 19, 2015 |
@ FRInteractives. Thanks |
| Re: How Can I Connect Php Script To Active Directory With XAMPP Server by FRInteractives: 11:55am On Mar 19, 2015 |
You're Welcome hundu: |
How To Increase Localhost Xampp Server Memory Limit ! • HELP - Installing A PHP Script On My Website Using GITHUB • Installing Joomla With Xampp (local Host Sever) • 2 • 3 • 4
Recover Deleted Notes On Iphone Via Iphone Recovery Software • How Does 2go And Related Phone Applications Really Work? • [Advice] Please How do I become a Programmer?
;