WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDESPHP CLASSESCODE SEARCHARTICLES SEARCHPHP FORUMSPHP MANUALPHP FUNCTIONS LISTWEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Join us on FaceBook
Submit a code Example / Snippet Submit Your Code
Poker Tournaments Poker Tournaments
Poker Guide for Developers Poker Guide for Developers
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Resources
Web Development Content
Internet Security Software
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
פרייסז - הכח לקנות עובר לידיים שלך
Texas Holdem Poker Evangelists

Go Back Add a Comment Send this example to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES ADD CODE EXAMPLES PRINT
Title : Windows 2003 Active Directory User Query (Ldap)
Categories : PHP, LDAP Click here to Update Your Picture
David Perez
Date : Apr 15th 2005
Grade : 4 of 5 (graded 4 times)
Viewed : 43803
File : No file for this code example.
Images : No Images for this code example.
Search : More code by David Perez
Action : Grade This Code Example
Tools : My Examples List

Submit your own code examples  Submit your own code examples 
 

<?
//Looking User Information into the Windows 2003 Active Directory
//Configurarion Section
$ldap_server="some.ip.addrr";             //The Active Directory Server
$ad_domainNB="someNBdomain";              //The Netbios name of the domain
$ad_domain="domain.com";             
$ad_user="user1";                         //Active Directory Valid User     
$ad_userPass="pass";                      //Active Directory Valid User Password
$user="user2";                            //Active Directory Valid User looking for
$domain_parts = explode(".",$ad_domain);  //Extract every part of the domain
$ad_base_search="";
for (
$x=0;$x<sizeof($domain_parts);$x++)  //Upper Case Parts and Build a base search string
{
     
$domain_parts[$x] = strtoupper($domain_parts[$x]);
     if (
$x==sizeof($domain_parts)-1)
         {
             
$ad_base_search .= "dc=" . $domain_parts[$x];
            }
        else
         {
             
$ad_base_search .= "dc=" . $domain_parts[$x] . ",";
            }   
    }

   
$ds=ldap_connect($ldap_server);//Conecting to the Server
if ($ds) //if Conection is ok we continue
{
       
//Setting the Ldap Query options
       
ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3);

       
//Setting the Ldap Query options
       
ldap_set_option($ds, LDAP_OPT_REFERRALS, 0);

       
//Validation with the Active Directory
       
@$r=ldap_bind($ds, $ad_domainNB . '\\' . $ad_user,$ad_userPass);

       
//Querying the Active Directory
       
@$sr=ldap_search($ds,$ad_base_search, "cn=" . $user);

       
//Fetching the result
       
@$info = ldap_get_entries($ds, $sr);

       
//Extracting the data
       
list($cn,$ou,$dc) = split(",",$info[0]["dn"]);

       
//Extracting the data
       
list($basura,$depto) = split("=",$ou);

       
//Formating Data Some Latin chars may not propertly shown
       
$nombre = utf8_decode($info[0]["displayname"][0]);
       
       
//Formating Data Some Latin chars may not propertly shown
       
$departamento = utf8_decode($depto);
}
// Closing LDAP Conection
@ldap_close($ds);                                                           

echo
$nombre ."<br>";
echo
$departamento . "<br>";
?>



ldap_add -- Add entries to LDAP directory
Categories : PHP, PHP Functions, LDAP
Authenticator for Exchange Server LDAP
Categories : PHP, Authentication, LDAP, Security, Sessions
Introduction to LDAP
Categories : LDAP, PHP
How to query a directory server using LDAP. Keywords: ldap_connect ldap_search
Categories : LDAP, Network, PHP
Query2Report : Generating Html, Pdf and Csv Reports from SQL Query
Categories : PHP, PHP, HTML, PDF, Excel
Authentication script to authenticate users in Active Directory through LDAP.
Categories : LDAP, Authentication, Cookies, PHP
A web-based php3 IMAP email client supporting address books, attachements (downloading and sending), LDAP searching, and much much more.
Categories : Email, PHP, LDAP
Calendar using Date function
Categories : HTML and PHP, PHP, Date Time, Calendar
Invision Forums Latest Threads list
Categories : PHP, Miscellaneous, Databases, MySQL
Pseudo Non Parsed Header. Output to the the browser as the script runs.
Categories : PHP, HTTP, HTML and PHP
UDMSearch - a free search engine, indexing system.
Categories : Search Engines, Linux, PHP, MySQL, ODBC
how to check if a string contains a letter from a different language?
Categories : PHP, Regexps, Languages
Class: Info on Users, Servers and the running script
Categories : PHP, Classes and Objects, User Interface, PHP Classes
PHP Domain Availability Checker
Categories : PHP, Complete Programs, Regexps, HTTP, Sockets
fforum fumanchi forum MySQL treestructure
Categories : Complete Programs, PHP, MySQL