@@ -29,7 +29,7 @@ class HomeController extends Controller
29
29
{
30
30
private const LOGKEY = 'CHc ' ;
31
31
32
- private const INTERNAL_POST = ['_auto_value ' ,'_key ' ,'_rdn ' ,'_rdn_value ' ,'_step ' ,'_template ' ,'_token ' ,'_userpassword_hash ' ];
32
+ private const INTERNAL_POST = ['_auto_value ' ,'_key ' ,'_rdn ' ,'_rdn_new ' , ' _rdn_value ' ,'_step ' ,'_template ' ,'_token ' ,'_userpassword_hash ' ];
33
33
34
34
/**
35
35
* Create a new object in the LDAP server
@@ -307,6 +307,31 @@ public function entry_pending_update(EntryRequest $request): \Illuminate\Http\Re
307
307
->with ('o ' ,$ o );
308
308
}
309
309
310
+ public function entry_rename (Request $ request ): \Illuminate \Http \RedirectResponse |\Illuminate \View \View
311
+ {
312
+ $ from_dn = Crypt::decryptString ($ request ->post ('dn ' ));
313
+ Log::info (sprintf ('%s:Renaming [%s] to [%s] ' ,self ::LOGKEY ,$ from_dn ,$ request ->post ('_rdn_new ' )));
314
+
315
+ $ o = config ('server ' )->fetch ($ from_dn );
316
+
317
+ if (! $ o )
318
+ return back ()
319
+ ->withInput ()
320
+ ->with ('note ' ,__ ('DN doesnt exist ' ));
321
+
322
+ try {
323
+ $ o ->rename ($ request ->post ('_rdn_new ' ));
324
+
325
+ } catch (\Exception $ e ) {
326
+ return Redirect::to ('/ ' )
327
+ ->with ('failed ' ,$ e ->getMessage ());
328
+ }
329
+
330
+ return Redirect::to ('/ ' )
331
+ ->withInput (['_key ' =>Crypt::encryptString ('*dn| ' .$ o ->getDN ())])
332
+ ->with ('success ' ,sprintf ('%s: %s ' ,__ ('Entry renamed ' ),$ from_dn ));
333
+ }
334
+
310
335
/**
311
336
* Update a DN entry
312
337
*
@@ -505,8 +530,8 @@ private function request_key(Request $request,?Collection $old=NULL): array
505
530
// Setup
506
531
$ cmd = NULL ;
507
532
$ dn = NULL ;
508
- $ key = $ request ->get ('_key ' ,old ('_key ' ))
509
- ? Crypt::decryptString ($ request -> get ( ' _key ' , old ( ' _key ' )) )
533
+ $ key = ( $ x = $ request ->get ('_key ' ,old ('_key ' ) ))
534
+ ? Crypt::decryptString ($ x )
510
535
: NULL ;
511
536
512
537
// Determine if our key has a command
@@ -518,9 +543,9 @@ private function request_key(Request $request,?Collection $old=NULL): array
518
543
$ dn = ($ m [2 ] !== '_NOP ' ) ? $ m [2 ] : NULL ;
519
544
}
520
545
521
- } elseif (old ('dn ' ,$ request ->get ('_key ' ))) {
546
+ } elseif ($ x = old ('dn ' ,$ request ->get ('_key ' ))) {
522
547
$ cmd = 'dn ' ;
523
- $ dn = Crypt::decryptString (old ( ' dn ' , $ request -> get ( ' _key ' )) );
548
+ $ dn = Crypt::decryptString ($ x );
524
549
}
525
550
526
551
return ['cmd ' =>$ cmd ,'dn ' =>$ dn ];
0 commit comments