Click here to get back home

unable to connect to active directory server

 HomeNewsGroups | Search | About
 comp.lang.php    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
unable to connect to active directory server yawnmoth 07-31-2008
Get Chitika Premium
Posted by yawnmoth on July 31, 2008, 6:42 pm
Please log in for more thread options
I'm trying to connect to an Active Directory server and am having some
difficulties. Here's the code I'm using:

<?php
if (!($ldap = ldap_connect('domain.tld'))
{
        exit('unable to connect');
}

ldap_bind($ldap, 'username', 'password');
?>

With that code, I get the following error:

Warning: ldap_bind() [function.ldap-bind]: Unable to bind to server:
Invalid credentials in C:\htdocs\test.php on line 10

The thing is... I can connect just fine using Active Directory
Explorer v1.01 [1] using the same info as above. The only thing I
can figure is that Active Directory Explorer is doing something that
PHP doesn't. Maybe it connects to a different port than PHP does by
default? Maybe it appends something to the username?

[1] http://www.microsoft.com/technet/sysinternals/networking/adexplorer.mspx

Posted by Charles Polisher on August 1, 2008, 8:42 pm
Please log in for more thread options
> I'm trying to connect to an Active Directory server and am having some
> difficulties. Here's the code I'm using:
>
><?php
> if (!($ldap = ldap_connect('domain.tld'))
> {
>         exit('unable to connect');
> }
>
> ldap_bind($ldap, 'username', 'password');
> ?>
>
> With that code, I get the following error:
>
> Warning: ldap_bind() [function.ldap-bind]: Unable to bind to server:
> Invalid credentials in C:\htdocs\test.php on line 10
>
> The thing is... I can connect just fine using Active Directory
> Explorer v1.01 [1] using the same info as above. The only thing I
> can figure is that Active Directory Explorer is doing something that
> PHP doesn't. Maybe it connects to a different port than PHP does by
> default? Maybe it appends something to the username?
>
> [1] http://www.microsoft.com/technet/sysinternals/networking/adexplorer.mspx

Can you run Wireshark on the two sets of transactions
and post the (sanitized) traces?


Posted by yawnmoth on August 4, 2008, 3:09 pm
Please log in for more thread options
> > I'm trying to connect to an Active Directory server and am having some
> > difficulties. =A0Here's the code I'm using:
>
> ><?php
> > if (!($ldap =3D ldap_connect('domain.tld'))
> > {
> > =A0 =A0exit('unable to connect');
> > }
>
> > ldap_bind($ldap, 'username', 'password');
> > ?>
>
> > With that code, I get the following error:
>
> > Warning: ldap_bind() [function.ldap-bind]: Unable to bind to server:
> > Invalid credentials in C:\htdocs\test.php on line 10
>
> > The thing is... =A0I can connect just fine using Active Directory
> > Explorer v1.01 [1] =A0using the same info as above. =A0The only thing I
> > can figure is that Active Directory Explorer is doing something that
> > PHP doesn't. =A0Maybe it connects to a different port than PHP does by
> > default? =A0Maybe it appends something to the username?
>
> > [1]http://www.microsoft.com/technet/sysinternals/networking/adexplorer.=
mspx
>
> Can you run Wireshark on the two sets of transactions
> and post the (sanitized) traces?

I actually figured it out - Active Directory Explorer automatically
appends the domain name to the username (eg. user@domain.tld), whereas
PHP, I guess, doesn't, and instead, requires you manually add it.

Posted by Zsolt on August 4, 2008, 9:55 pm
Please log in for more thread options
I was having the same issues when trying to use the ldap functions in
PHP so I created a class that utilizes ADSI instead of LDAP. You can
grab it here http://www.phpclasses.org/browse/package/4549.html. I
found that utilizing COM & ADSI made the whole thing alot easier.

> I'm trying to connect to an Active Directory server and am having some
> difficulties. =A0Here's the code I'm using:
>
> <?php
> if (!($ldap =3D ldap_connect('domain.tld'))
> {
> =A0 =A0 =A0 =A0 exit('unable to connect');
>
> }
>
> ldap_bind($ldap, 'username', 'password');
> ?>
>
> With that code, I get the following error:
>
> Warning: ldap_bind() [function.ldap-bind]: Unable to bind to server:
> Invalid credentials in C:\htdocs\test.php on line 10
>
> The thing is... =A0I can connect just fine using Active Directory
> Explorer v1.01 [1] =A0using the same info as above. =A0The only thing I
> can figure is that Active Directory Explorer is doing something that
> PHP doesn't. =A0Maybe it connects to a different port than PHP does by
> default? =A0Maybe it appends something to the username?
>
> [1]http://www.microsoft.com/technet/sysinternals/networking/adexplorer.ms=
px


Similar ThreadsPosted
unable to connect to mssql server May 29, 2008, 8:49 am
Access Active Directory (of WINDOWS SERVER 2003) via LDAP February 28, 2006, 8:48 am
PHP and Active Directory 2K3 April 19, 2005, 10:19 am
php + Active Directory June 3, 2005, 10:11 am
PHP and Active Directory September 15, 2005, 9:46 am
PHP and Active Directory November 27, 2005, 4:36 pm
FTP unable to connect with fsockopen November 2, 2007, 11:28 am
Active directory authentication via php. April 16, 2007, 1:30 pm
creating active directory user February 9, 2005, 5:24 am
Retrieving information from Active Directory through OLE-DB August 26, 2006, 9:14 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap