add new methods to ldap class
authorStricted <info@nexus-irc.de>
Fri, 21 Feb 2014 01:16:53 +0000 (02:16 +0100)
committerStricted <info@nexus-irc.de>
Fri, 21 Feb 2014 01:16:53 +0000 (02:16 +0100)
LDAP.class.php

index d0ede6e8a505cc0d563808d0549549728b1dec99..32588abed83c30900841955c174bb639cc2f456c 100644 (file)
@@ -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
         *