Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Created LDAP library. Defined LDAP connection function.
- Loading branch information
1 parent
c19a987
commit 07e70f2
Showing
2 changed files
with
47 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
|
||
/* | ||
Attempt to connect to LDAP server | ||
If successful return connection string | ||
Otherwise return false | ||
*/ | ||
function my_ldap_connect(){ | ||
global $ldap_server; | ||
|
||
// Connect to LDAP server | ||
$conn = ldap_connect($ldap_server['hostname'], $ldap_server['port']); | ||
if ($conn) { | ||
// Set Protocol Version | ||
ldap_set_option($conn, LDAP_OPT_PROTOCOL_VERSION, $ldap_server['protocol_version']); | ||
|
||
// Bind to LDAP server | ||
$bind = ldap_bind($conn, $ldap_server['bind_rdn'], $ldap_server['bind_pass']); | ||
|
||
if ($bind) { | ||
return $conn; | ||
} | ||
} | ||
return false; | ||
} | ||
|
||
?> |