From 765a24f38bda91a0dcfc0dc7ee970ce9d558a664 Mon Sep 17 00:00:00 2001 From: Stricted Date: Fri, 21 Feb 2014 02:16:53 +0100 Subject: [PATCH] add new methods to ldap class --- LDAP.class.php | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/LDAP.class.php b/LDAP.class.php index d0ede6e..32588ab 100644 --- a/LDAP.class.php +++ b/LDAP.class.php @@ -51,6 +51,51 @@ class LDAP { return false; } + /** + * add a user to ldap server + * + * @param array $user + * @return boolean + */ + public function addUser (Array $user) { + /* + Eampel: + $user = array(); + $user['dn'] = 'uid=testuser,ou=Users,dc=ldap,dc=test,dc=server,dc=com'; + $user['objectClass'] = array('inetOrgPerson', 'organizationalPerson', 'posixAccount'); + $user['cn'] = 'Test User'; + $user['gidNumber'] = '5001'; + $user['homeDirectory'] = '/home/testuser'; + $user['sn'] = 'User'; + $user['uid'] = 'testuser'; + $user['uidNumber'] = '5001'; + $user['loginShell'] = '/bin/bash'; + $user['mail'] = 'test@user.com'; + $user['userPassword'] = ''; + */ + if (is_array($user) && !empty($user)) { + if (ldap_add($this->ldap, $this->dn, $user) { + return true; + } + } + + return false; + } + + /** + * delete ldap user + * + * @param string $user + * @return boolean + */ + public function delUser ($user) { + if (ldap_delete ($this->ldap, $user.",".$this->dn)) { + return true; + } + + return false; + } + /** * returns ldap user array * -- 2.20.1