WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDES  |  PHP CLASSES  |  CODE SEARCH  |  ARTICLES SEARCH  |  PHP FORUMS  |  PHP MANUAL  |  PHP FUNCTIONS LIST  |  WEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Submit Your Code
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
WeberDev's Monthly code contest PHP Code Contest
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 Index
PHP Web Logs (BLogs)
Web Development Resources
Web Development Content
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
Submit Site
Forex Trading Online forex trading platform

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 3 times)
Viewed : 17400
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 
 

<?
//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>";
?>



Authentication script to authenticate users in Active Directory through LDAP.
Categories : LDAP, Authentication, Cookies, PHP
ldap_add -- Add entries to LDAP directory
Categories : PHP, PHP Functions, LDAP
A web-based php3 IMAP email client supporting address books, attachements (downloading and sending), LDAP searching, and much much more.
Categories : Email, PHP, LDAP
Introduction to LDAP
Categories : LDAP, PHP
Authenticator for Exchange Server LDAP
Categories : PHP, Authentication, LDAP, Security, Sessions
Query2Report : Generating Html, Pdf and Csv Reports from SQL Query
Categories : PHP, PHP, HTML, PDF, Excel
How to query a directory server using LDAP. Keywords: ldap_connect ldap_search
Categories : LDAP, Network, PHP
Retrieve text from table and email to your e- address in pipe delimited format.
Categories : PHP, MySQL
Accepts a database & hostname from a user and then HTTP username and password. Uses this to connect to a MySQL database. Produces a form based on the tables it finds there to allow the user to do SELECTs, INSERTs, and DELETEs.
Categories : Databases, PHP, MySQL, Complete Programs
A PHP function to encrypt and decrypt a number or string or a combination of the two.
Categories : PHP, Encryption, Security
Using $PHP_AUTH_USER and $PHP_AUTH_PW to authenticate.
Categories : Authentication, PHP
file class , uploade file , download file already uploaded on another website
Categories : PHP, PHP Classes, Filesystem, Web Services
Authorize.net AIM Interface Class v1.0.0
Categories : PHP, PHP Classes, Ecommerce, Payment Gateways
Function to remember password
Categories : PHP, Authentication, Personalization and Membership
Create Thumbnails - resize an image - jpeg, jpg, gif, png to the specifed width and height in proportion without loosing out on pixcel quality.
Categories : PHP, GD image library, Graphics