@@ -58,10 +58,7 @@ public function init($send_mail = true)
58
58
if (!$ ldapGroupEntry ->exists ()) {
59
59
$ ldapGroupEntry ->setAttribute ("objectclass " , UnityLDAP::POSIX_GROUP_CLASS );
60
60
$ 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 ();
65
62
}
66
63
67
64
//
@@ -80,11 +77,7 @@ public function init($send_mail = true)
80
77
$ ldapUserEntry ->setAttribute ("loginshell " , $ this ->LDAP ->getDefUserShell ());
81
78
$ ldapUserEntry ->setAttribute ("uidnumber " , strval ($ id ));
82
79
$ 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 ();
88
81
}
89
82
90
83
// update cache
@@ -177,11 +170,7 @@ public function setOrg($org)
177
170
{
178
171
$ ldap_user = $ this ->getLDAPUser ();
179
172
$ 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 ();
185
174
$ this ->REDIS ->setCache ($ this ->uid , "org " , $ org );
186
175
}
187
176
@@ -225,10 +214,7 @@ public function setFirstname($firstname, $operator = null)
225
214
$ this ->getUID ()
226
215
);
227
216
228
- if (!$ ldap_user ->write ()) {
229
- throw new Exception ("Error updating LDAP entry $ this ->uid " );
230
- }
231
-
217
+ $ ldap_user ->write ();
232
218
$ this ->REDIS ->setCache ($ this ->uid , "firstname " , $ firstname );
233
219
}
234
220
@@ -277,10 +263,7 @@ public function setLastname($lastname, $operator = null)
277
263
$ this ->getUID ()
278
264
);
279
265
280
- if (!$ this ->getLDAPUser ()->write ()) {
281
- throw new Exception ("Error updating LDAP entry $ this ->uid " );
282
- }
283
-
266
+ $ this ->getLDAPUser ()->write ();
284
267
$ this ->REDIS ->setCache ($ this ->uid , "lastname " , $ lastname );
285
268
}
286
269
@@ -334,10 +317,7 @@ public function setMail($email, $operator = null)
334
317
$ this ->getUID ()
335
318
);
336
319
337
- if (!$ this ->getLDAPUser ()->write ()) {
338
- throw new Exception ("Error updating LDAP entry $ this ->uid " );
339
- }
340
-
320
+ $ this ->getLDAPUser ()->write ();
341
321
$ this ->REDIS ->setCache ($ this ->uid , "mail " , $ email );
342
322
}
343
323
@@ -380,9 +360,7 @@ public function setSSHKeys($keys, $operator = null, $send_mail = true)
380
360
$ keys_filt = array_values (array_unique ($ keys ));
381
361
if ($ ldapUser ->exists ()) {
382
362
$ 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 ();
386
364
}
387
365
388
366
$ this ->REDIS ->setCache ($ this ->uid , "sshkeys " , $ keys_filt );
@@ -451,9 +429,7 @@ public function setLoginShell($shell, $operator = null, $send_mail = true)
451
429
$ ldapUser = $ this ->getLDAPUser ();
452
430
if ($ ldapUser ->exists ()) {
453
431
$ ldapUser ->setAttribute ("loginshell " , $ shell );
454
- if (!$ ldapUser ->write ()) {
455
- throw new Exception ("Failed to modify login shell for $ this ->uid " );
456
- }
432
+ $ ldapUser ->write ();
457
433
}
458
434
459
435
$ operator = is_null ($ operator ) ? $ this ->getUID () : $ operator ->getUID ();
@@ -510,10 +486,7 @@ public function setHomeDir($home, $operator = null)
510
486
$ ldapUser = $ this ->getLDAPUser ();
511
487
if ($ ldapUser ->exists ()) {
512
488
$ 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 ();
517
490
$ operator = is_null ($ operator ) ? $ this ->getUID () : $ operator ->getUID ();
518
491
519
492
$ this ->SQL ->addLog (
0 commit comments