LDAP Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesLDAP Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
  #1  
Old February 4th, 2008, 12:12 PM
Kiekeboe100 Kiekeboe100 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2008
Location: Belgium
Posts: 2 Kiekeboe100 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 39 m 7 sec
Reputation Power: 0
PHP Get group list from user

hello,

first of all, I am a complete noob when it comes to LDAP

I'm trying to use php to get the group list from a user. I've searched on the internet, this forums but I can't find a solution, and I don't have any idea on how to start with this.

The username i have is in the form of DOMAIN\username.

Another problem is that when I try the sample code on php.net I can't get it to show the data.

The domain is on a win2003 server. The Forest functional level is Windows 2000, and the Domain functional level Windows Server 2003.

I'm using php5 on an iis 6 server, and the ldap extension is enabled.

The php sample file:
PHP Code:
<?php
// basic sequence with LDAP is connect, bind, search, interpret search
// result, close connection

echo "<h3>LDAP query test</h3>";
echo 
"Connecting ...";
$ds=ldap_connect("srvr-isa");  // must be a valid LDAP server!
echo "connect result is " $ds "<br />";

if (
$ds) { 
    echo 
"Binding ..."
    
$r=ldap_bind($ds);     // this is an "anonymous" bind, typically
                           // read-only access
    
echo "Bind result is " $r "<br />";

    echo 
"Searching for (sn=*) ...";
    
// Search surname entry
    
$sr=ldap_search($ds"o=Hoefman, c=BE""sn=*");  
    echo 
"Search result is " $sr "<br />";

    echo 
"Number of entires returned is " ldap_count_entries($ds$sr) . "<br />";

    echo 
"Getting entries ...<p>";
    
$info ldap_get_entries($ds$sr);
    echo 
"Data for " $info["count"] . " items returned:<p>";

    for (
$i=0$i<$info["count"]; $i++) {
        echo 
"dn is: " $info[$i]["dn"] . "<br />";
        echo 
"first cn entry is: " $info[$i]["cn"][0] . "<br />";
        echo 
"first email entry is: " $info[$i]["mail"][0] . "<br /><hr />";
    }

    echo 
"Closing connection";
    
ldap_close($ds);

} else {
    echo 
"<h4>Unable to connect to LDAP server</h4>";
}
?>

And this is the output:
Code:
LDAP query test
Connecting ...connect result is Resource id #1
Binding ...Bind result is 1
Searching for (sn=*) ...Search result is 
Number of entires returned is 
Getting entries ...

Data for items returned:

Closing connection

thx,
Stijn

Last edited by Kiekeboe100 : February 4th, 2008 at 12:23 PM. Reason: added php5, iis6, ...

Reply With Quote
  #2  
Old February 4th, 2008, 12:30 PM
Kiekeboe100 Kiekeboe100 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2008
Location: Belgium
Posts: 2 Kiekeboe100 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 39 m 7 sec
Reputation Power: 0
really sorry about the editting and replying but I think i've got everything now.

I've enabled the errors in php and now i'm getting some errors when going to the sample script.

Code:
LDAP query test
Connecting ...connect result is Resource id #1
Binding ...Bind result is 1
Searching for (sn=*) ...
Warning: ldap_search() [function.ldap-search]: Search: Operations error in D:\Server Data\Intranet Site\ldap.php on line 18
Search result is 

Warning: ldap_count_entries(): supplied argument is not a valid ldap result resource in D:\Server Data\Intranet Site\ldap.php on line 21
Number of entires returned is 
Getting entries ...


Warning: ldap_get_entries(): supplied argument is not a valid ldap result resource in D:\Server Data\Intranet Site\ldap.php on line 24
Data for items returned:

Closing connection

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesLDAP Programming > PHP Get group list from user


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

 Free IT White Papers!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five "checkpoints" for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway