2020-08-27 12:46:07 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
|
|
|
|
use Illuminate\Http\Request;
|
2020-09-14 11:08:55 +00:00
|
|
|
use Illuminate\Support\Arr;
|
2020-08-27 12:46:07 +00:00
|
|
|
use Illuminate\Support\Facades\Crypt;
|
2020-08-31 11:41:45 +00:00
|
|
|
use Illuminate\Support\Facades\Log;
|
2020-09-13 13:41:26 +00:00
|
|
|
use LdapRecord\Query\Collection;
|
2020-08-27 12:46:07 +00:00
|
|
|
|
|
|
|
use App\Classes\LDAP\Server;
|
|
|
|
|
|
|
|
class APIController extends Controller
|
|
|
|
{
|
2020-09-13 13:41:26 +00:00
|
|
|
/**
|
|
|
|
* @param Request $request
|
|
|
|
* @return Collection
|
|
|
|
*/
|
2020-09-14 11:08:55 +00:00
|
|
|
public function children(Request $request): Collection
|
2020-08-31 11:41:45 +00:00
|
|
|
{
|
|
|
|
$levels = $request->query('depth',1);
|
|
|
|
$dn = Crypt::decryptString($request->query('key'));
|
|
|
|
Log::debug(sprintf('%s: Query [%s] - Levels [%d]',__METHOD__,$dn,$levels));
|
|
|
|
|
|
|
|
return (new Server())
|
2020-09-14 11:08:55 +00:00
|
|
|
->children($dn)
|
2020-08-31 11:41:45 +00:00
|
|
|
->transform(function($item) {
|
|
|
|
return [
|
2020-09-14 11:08:55 +00:00
|
|
|
'title'=>$item->getRdn(),
|
2020-09-13 13:41:26 +00:00
|
|
|
'item'=>Crypt::encryptString($item->getDn()),
|
2020-09-23 12:14:38 +00:00
|
|
|
'icon'=>$item->icon(),
|
2020-09-14 11:08:55 +00:00
|
|
|
'lazy'=>Arr::get($item->getAttribute('hassubordinates'),0) == 'TRUE',
|
2020-09-13 13:41:26 +00:00
|
|
|
'tooltip'=>$item->getDn(),
|
2020-08-31 11:41:45 +00:00
|
|
|
];
|
|
|
|
});
|
2020-08-27 12:46:07 +00:00
|
|
|
}
|
2023-02-14 10:38:42 +00:00
|
|
|
|
|
|
|
public function schema_view(Request $request)
|
|
|
|
{
|
|
|
|
$server = new Server;
|
|
|
|
|
|
|
|
switch($request->type) {
|
|
|
|
case 'objectclasses':
|
|
|
|
return view('frames.schema.objectclasses')
|
|
|
|
->with('objectclasses',$server->schema('objectclasses')->sortBy(function($item) { return strtolower($item->name); }));
|
|
|
|
|
|
|
|
case 'attributetypes':
|
|
|
|
return view('frames.schema.attributetypes')
|
|
|
|
->with('server',$server)
|
|
|
|
->with('attributetypes',$server->schema('attributetypes')->sortBy(function($item) { return strtolower($item->name); }));
|
|
|
|
|
|
|
|
case 'ldapsyntaxes':
|
|
|
|
return view('frames.schema.ldapsyntaxes')
|
|
|
|
->with('ldapsyntaxes',$server->schema('ldapsyntaxes')->sortBy(function($item) { return strtolower($item->description); }));
|
|
|
|
|
|
|
|
case 'matchingrules':
|
|
|
|
return view('frames.schema.matchingrules')
|
|
|
|
->with('matchingrules',$server->schema('matchingrules')->sortBy(function($item) { return strtolower($item->name); }));
|
|
|
|
|
|
|
|
default:
|
|
|
|
abort(404);
|
|
|
|
}
|
|
|
|
}
|
2020-08-27 12:46:07 +00:00
|
|
|
}
|