Login   Register  
PHP Classes
elePHPant
Icontem

File: usage.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Leigh Edwards  >  PHP LDAP  >  usage.php  >  Download  
File: usage.php
Role: Example script
Content type: text/plain
Description: usage example
Class: PHP LDAP
Authenticate users connecting to a LDAP server
Author: By
Last change: file rename
Date: 2012-10-27 22:25
Size: 969 bytes
 

Contents

Class file image Download
<?php 
session_start 
();
require_once 
'class.PHPLdap.php';
$ldap = new PHPLdap();
$ldap->setLDAPServer('123.123.123.123'); // LDAP Server Address
$ldap->setLDAPTLD(''); // Top-level domain such as .com and .net and .org
$ldap->setLDAPDomain(''); //Second-level domain (SLD) names. These are the names directly to the left of .com, .net

$ldap->setLDAPUser(''); // LDAP user to perform LDAP requests
$ldap->setLDAPPassword(''); // pass word for the LDAP user
$ldap->connect(); // connect to the ldap server


// Simple logi script using the PHPLdap class

$groupName 'IT';

include (
'login.php');


if (
$ldap->loggedIn ())
{
    
?>You are logged in <?php
    
    
if ($ldap->isMemberOfGroup $_SESSION ['username'], $groupName )){
        
?>to the given group <?=$groupName?><?php
    
}else{
        
?>but you are not a member of the given group <?=$groupName?><?php
    
}
    
}else{
    
?>You are not logged in. Please use the form above  to gain access<?php
}

?>