PHP Classes

File: usage.php

Recommend this page to a friend!
  Classes of Leigh Edwards  >  PHP LDAP  >  usage.php  >  Download  
File: usage.php
Role: Example script
Content type: text/plain
Description: usage example
Authenticate users connecting to a LDAP server
Author: By
Last change: file rename
Date: 10 years ago
Size: 969 bytes


Class file image Download
$ldap = new PHPLdap();
$ldap->setLDAPServer(''); // 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 (

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