Documentation

main

Represents the main class for LDAP operations.

Table of Contents

Properties

$base  : string
$bind  : resource
Represents the bind of ldap.
$dom  : string
$lconn  : Connection

Methods

__construct()  : void
Construct method for the class.
__destruct()  : mixed
Closes the LDAP connection when the object is destroyed.
login()  : array<string|int, mixed>|bool
Authenticates a user and retrieves their LDAP information.
search()  : bool
Searches for a user in the LDAP directory.
checkdisabled()  : array<string|int, mixed>|bool
Checks the disabled flags based on the given user account value.
connect()  : void
Establishes a connection with the LDAP server.
getldaparray()  : array<string|int, mixed>
Returns an array with LDAP user information.
getsid()  : string
Converts an Active Directory SID (Security Identifier) from binary to string format.
ldap_login()  : bool
Attempts to log in to the LDAP directory with the given user and password.

Properties

$base

private string $base

Represents the base DN for LDAP operations. The base DN is the starting point for querying the LDAP directory.

$bind

Represents the bind of ldap.

private resource $bind

$dom

private string $dom

Represents the ldap domain.

$lconn

private Connection $lconn

Represents the connection to the LDAP server.

Methods

__construct()

Construct method for the class.

public __construct() : void

The method initiates the connection to the LDAP directory by calling the 'connect' method.

__destruct()

Closes the LDAP connection when the object is destroyed.

public __destruct() : mixed

login()

Authenticates a user and retrieves their LDAP information.

public login(string $user, string $pass) : array<string|int, mixed>|bool
Parameters
$user : string

The username of the user attempting to login.

$pass : string

The password of the user attempting to login.

Return values
array<string|int, mixed>|bool —

Returns an array of LDAP information if the user is authenticated and has LDAP information, false otherwise.

Searches for a user in the LDAP directory.

public search(string $user) : bool
Parameters
$user : string

The user to search for.

Return values
bool —

Returns true if the user is found and meets the required conditions, false otherwise.

checkdisabled()

Checks the disabled flags based on the given user account value.

private checkdisabled(string $usAcc) : array<string|int, mixed>|bool
Parameters
$usAcc : string

The user account value to check.

Return values
array<string|int, mixed>|bool —

Returns an array of disabled flags if there are any, otherwise false.

connect()

Establishes a connection with the LDAP server.

private connect() : void

getldaparray()

Returns an array with LDAP user information.

private getldaparray(string $user, string $pass, array<string|int, mixed> $info) : array<string|int, mixed>
Parameters
$user : string

The username.

$pass : string

The user's password.

$info : array<string|int, mixed>

An array containing LDAP user information.

Return values
array<string|int, mixed> —

An array with the following keys:

  • 'user' : The username.
  • 'pass' : The encrypted password.
  • 'company' : The user's company.
  • 'cn' : The user's common name.
  • 'first' : The user's first name.
  • 'last' : The user's last name.
  • 'direct' : The user's direct phone number, or 0 if not available.
  • 'phone' : The user's phone number, or 0 if not available.
  • 'mobile' : The user's mobile number, or 0 if not available.
  • 'email' : The user's email, or an empty string if not available.

getsid()

Converts an Active Directory SID (Security Identifier) from binary to string format.

private getsid(string $adsid) : string
Parameters
$adsid : string

The binary representation of the Active Directory SID.

Return values
string —

The string representation of the Active Directory SID.

ldap_login()

Attempts to log in to the LDAP directory with the given user and password.

private ldap_login(string $user, string $pass) : bool
Parameters
$user : string

The username to log in with.

$pass : string

The password for the user.

Return values
bool —

Returns true if the login is successful, false otherwise.


        
On this page

Search results