Hello,

Should start off my saying I do not know about Active Directory 
specifically, but I have used the PHP LDAP support a lot against other 
directory servers.

What I see straight off is that $user_dn does not look like a 
distinguished name.  I would have expected something like:

 $user_dn = "uid=username,ou=people,dc=mydomain,dc=myschools,dc=org";

Also, while you can bind as someone, you may not need to.  Just to see 
if you can get anything back you might try binding anonymously and just 
printing something the common name.

Finally, it can really be helpful to test your queries with a simple 
ldap tool like ldapsearch.  If you have access to a Linux box somewhere 
ldapsearch is just part of the tool set.

Bill

--On Tuesday, February 25, 2003 10:06:21 PM -0500 Ezra Nugroho 
<[EMAIL PROTECTED]> wrote:

>
>
> This one is really puzzling...
> It has taken me days..
>
> I need to do an LDAP search to an Active Directory server.
> I was able to connect and bind to the server fine, but my searches
> are always in vain. OK, here we go:
>
> box name: mydomain-71.mydomain.myschools.org
> domain name: mydomain.myschools.org
> user to search: [EMAIL PROTECTED]
> (names and and passwords are of course ficticious)
>
> my code:
>
> <?
>
> $user_dn = "[EMAIL PROTECTED]";
> $base_dn = "dc=mydomain,dc=myschools,dc=org";
> $server = "mydomain-71.mydomain.myschools.org";
>
> echo $conn = ldap_connect($server);
> echo "AUTH: ". $bind = ldap_bind($conn, $user_dn,"password");
>
> $user = "ez";
> $filter = (|(name=$name*)(displayname=$name*)(cn=$name*));
>
> $res = ldap_search($conn,$base_dn,$filter);
> $info = ldap_get_entries($conn, $res);
>
> print_r($info);
>
> ?>
>
> it gives me:
>
> Resource id #1
> AUTH: 1
>
> Warning: LDAP: Unable to perform the search: can't contact LDAP
> server in ldap_test.php on line 16
>
> Warning: ldap_get_entres(): supplied argument is not a valid ldap
> result resource  blah  blah...
>
> Now, I was able to connect and authenticate to it, but why
> ldap_search() says that I can't connect to it?
>
>
> If I change $base_dn to
> "dc=mydomain-71,dc=mydomain,dc=myschools,dc=org"; The error message
> is changed to :
> Unable to perform the search: No such object in ldap_test.php on line
> 16.
>
> It doesn't complain about not being able to connect anymore! But of
> course the search fails because the domain really is only
> mydomain.myschools.org.
>
> What on earth did I do wrong??
>
> Thanks,
>
> -------------------------------------------------
> This mail sent through IMP: http://horde.org/imp/
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>



+----------------------------------------------------
| Bill MacAllister
| 14219 Auburn Road
| Grass Valley, CA 95949
| Phone: 530-272-8555

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to