-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommonWebLibrary_sms.php
More file actions
executable file
·32 lines (28 loc) · 1.01 KB
/
commonWebLibrary_sms.php
File metadata and controls
executable file
·32 lines (28 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<?php
# Michael Bisbjerg, 2010, All rights reserved.
require_once('commonWebLibrary.php');
class Sms extends commonLibrary
{
const LDAP_USER = 'xxx';
const LDAP_PASS = 'xxx';
// private helper method.
protected static function _getMembers($filter)
{
$ldapconn = ldap_connect(self::LDAP_HOST, self::LDAP_PORT) or die("Could not connect to ".self::LDAP_HOST);
@ldap_bind($ldapconn, self::LDAP_USER, self::LDAP_PASS);
$result = ldap_search($ldapconn, self::LDAP_DN_USERS, $filter, array('uid', 'uidnumber', 'cn', 'mobile'));
$data = ldap_get_entries($ldapconn, $result);
$users = array();
for ($i = 0; $i < $data['count']; $i++) {
$users[$data[$i]['uid'][0]] = array('cn' => $data[$i]['cn'][0], 'uid' => $data[$i]['uidnumber'][0], 'mobile' => $data[$i]['mobile'][0]);
}
ksort($users, SORT_STRING);
return $users;
}
public static function getMember($nick)
{
$members = self::_getMembers("(&(objectClass=posixAccount)(uid=$nick))");
return (object) (count($members) == 0 ? null : $members[$nick]);
}
}
?>