@@ -58,10 +58,7 @@ public function init($send_mail = true)
5858 if (!$ ldapGroupEntry ->exists ()) {
5959 $ ldapGroupEntry ->setAttribute ("objectclass " , UnityLDAP::POSIX_GROUP_CLASS );
6060 $ ldapGroupEntry ->setAttribute ("gidnumber " , strval ($ id ));
61-
62- if (!$ ldapGroupEntry ->write ()) {
63- throw new Exception ("Failed to create POSIX group for $ this ->uid " );
64- }
61+ $ ldapGroupEntry ->write ();
6562 }
6663
6764 //
@@ -80,11 +77,7 @@ public function init($send_mail = true)
8077 $ ldapUserEntry ->setAttribute ("loginshell " , $ this ->LDAP ->getDefUserShell ());
8178 $ ldapUserEntry ->setAttribute ("uidnumber " , strval ($ id ));
8279 $ ldapUserEntry ->setAttribute ("gidnumber " , strval ($ id ));
83-
84- if (!$ ldapUserEntry ->write ()) {
85- $ ldapGroupEntry ->delete (); // Cleanup previous group
86- throw new Exception ("Failed to create POSIX user for $ this ->uid " );
87- }
80+ $ ldapUserEntry ->write ();
8881 }
8982
9083 // update cache
@@ -177,11 +170,7 @@ public function setOrg($org)
177170 {
178171 $ ldap_user = $ this ->getLDAPUser ();
179172 $ ldap_user ->setAttribute ("o " , $ org );
180-
181- if (!$ ldap_user ->write ()) {
182- throw new Exception ("Error updating LDAP entry $ this ->uid " );
183- }
184-
173+ $ ldap_user ->write ();
185174 $ this ->REDIS ->setCache ($ this ->uid , "org " , $ org );
186175 }
187176
@@ -225,10 +214,7 @@ public function setFirstname($firstname, $operator = null)
225214 $ this ->getUID ()
226215 );
227216
228- if (!$ ldap_user ->write ()) {
229- throw new Exception ("Error updating LDAP entry $ this ->uid " );
230- }
231-
217+ $ ldap_user ->write ();
232218 $ this ->REDIS ->setCache ($ this ->uid , "firstname " , $ firstname );
233219 }
234220
@@ -277,10 +263,7 @@ public function setLastname($lastname, $operator = null)
277263 $ this ->getUID ()
278264 );
279265
280- if (!$ this ->getLDAPUser ()->write ()) {
281- throw new Exception ("Error updating LDAP entry $ this ->uid " );
282- }
283-
266+ $ this ->getLDAPUser ()->write ();
284267 $ this ->REDIS ->setCache ($ this ->uid , "lastname " , $ lastname );
285268 }
286269
@@ -334,10 +317,7 @@ public function setMail($email, $operator = null)
334317 $ this ->getUID ()
335318 );
336319
337- if (!$ this ->getLDAPUser ()->write ()) {
338- throw new Exception ("Error updating LDAP entry $ this ->uid " );
339- }
340-
320+ $ this ->getLDAPUser ()->write ();
341321 $ this ->REDIS ->setCache ($ this ->uid , "mail " , $ email );
342322 }
343323
@@ -380,9 +360,7 @@ public function setSSHKeys($keys, $operator = null, $send_mail = true)
380360 $ keys_filt = array_values (array_unique ($ keys ));
381361 if ($ ldapUser ->exists ()) {
382362 $ ldapUser ->setAttribute ("sshpublickey " , $ keys_filt );
383- if (!$ ldapUser ->write ()) {
384- throw new Exception ("Failed to modify SSH keys for $ this ->uid " );
385- }
363+ $ ldapUser ->write ();
386364 }
387365
388366 $ this ->REDIS ->setCache ($ this ->uid , "sshkeys " , $ keys_filt );
@@ -451,9 +429,7 @@ public function setLoginShell($shell, $operator = null, $send_mail = true)
451429 $ ldapUser = $ this ->getLDAPUser ();
452430 if ($ ldapUser ->exists ()) {
453431 $ ldapUser ->setAttribute ("loginshell " , $ shell );
454- if (!$ ldapUser ->write ()) {
455- throw new Exception ("Failed to modify login shell for $ this ->uid " );
456- }
432+ $ ldapUser ->write ();
457433 }
458434
459435 $ operator = is_null ($ operator ) ? $ this ->getUID () : $ operator ->getUID ();
@@ -510,10 +486,7 @@ public function setHomeDir($home, $operator = null)
510486 $ ldapUser = $ this ->getLDAPUser ();
511487 if ($ ldapUser ->exists ()) {
512488 $ ldapUser ->setAttribute ("homedirectory " , $ home );
513- if (!$ ldapUser ->write ()) {
514- throw new Exception ("Failed to modify home directory for $ this ->uid " );
515- }
516-
489+ $ ldapUser ->write ();
517490 $ operator = is_null ($ operator ) ? $ this ->getUID () : $ operator ->getUID ();
518491
519492 $ this ->SQL ->addLog (
0 commit comments