Navigate
Home
ArticleWiki
Forum
Journal
Search
Newsletter
Links
Tech News
expertsrt.com
Welcome Guest.
Username:

Password:

Remember me

ldap_bind Error Invalid Credentials
Welcome, Guest. Please login or register.
December 01, 2008, 07:08:16 PM
11304 Posts in 1248 Topics by 496 Members
Latest Member: teentiodo
Experts Round Table Network  |  Serverside Technology  |  PHP  |  ldap_bind Error Invalid Credentials « previous next »
Pages: [1]
Author Topic: ldap_bind Error Invalid Credentials  (Read 457 times)
sajuks
Site Builder

Offline Offline

Posts: 18


« on: July 24, 2006, 09:31:00 PM »

Uisng PHP5 ,APACHE2 trying to use LDAP authentication.

Have LDAP enabled in my php,ini
LDAP Support                  enabled 
RCS Version                    $Id: ldap.c,v 1.161.2.3 2006/01/01 12:50:08 sniper Exp $ 
Total Links                       0/unlimited 
API Version                     2004 
Vendor Name                  OpenLDAP 
Vendor Version               0 

Am trying this simple code and it gives me an error
"Unable to bind to server: Can't contact LDAP server "
$ad = ldap_connect("ldap://XXX.X.XX.XXX") or die("Couldn't connect to AD!");
ldap_set_option($ad, LDAP_OPT_PROTOCOL_VERSION, 3);
ldap_set_option($ad, LDAP_OPT_REFERRALS, 0);
$user ="ksaju@ABCD.com";
$bd = ldap_bind($ad,$user,"mypassword") or die("Couldn't bind to AD!" );

What info is required to allow successfule bind ?
When i do an anonymous search it allows me to do so as our system does allow Anonymous binding.

Posted on: July 24, 2006, 09:19:13 AM
Forget it...Our network admin in his infinite wisdom gave me the wrong IP address.
Logged
seandelaney
Mentor

Offline Offline

Posts: 119



WWW
« Reply #1 on: December 19, 2006, 02:03:14 AM »

Hi sajuks,

I struggled for weeks on this issue, but finally got it working by downloading LDAP browser.  I then connected to AD and the LDAP browser give me the connection string to use in the PHP....

below is my example that i use...  if you need more advanced example, as ive got a few, just ask...

hope it helps Sean

Code
Language: php (GeSHi-highlighted)
<?php
$active_directory = ldap_connect('abz.pegasus-international.com') or die('Connection to Active Directory Failed');
ldap_set_option($active_directory, LDAP_OPT_PROTOCOL_VERSION, 3);
ldap_set_option($active_directory, LDAP_OPT_REFERRALS, 0);
$bind_data = ldap_bind($active_directory,'administrator@abz.pegasus-international.com','password') or die('Binding to Active Directory Failed');
$fields = array('givenname','sn','mail');
$filter = '(cn=*)';
 
$administration = 'OU=Administration,OU=Pegasus International Users,DC=abz,DC=pegasus-international,DC=com';
$result = ldap_search($active_directory,$administration,$filter,$fields);
$entries = ldap_get_entries($active_directory, $result);
 
for ($idx = 0; $idx < $entries['count']; $idx++)
{
$surnames = $entries[$idx]['sn'][0];
}
 
echo '<pre>';
print_r($surnames);
echo '</pre>';
?>
Logged

Pages: [1]
« previous next »
    Jump to: