API query and CI to build the docker demo image
Remove unused CI, removed some debugging for the demo
This commit is contained in:
@@ -18,6 +18,7 @@ class Server
|
||||
*/
|
||||
public function getBaseDN(): ?Collection
|
||||
{
|
||||
//findBaseDn()?
|
||||
// If the base is set in the configuration file, then just return that after validating it exists.
|
||||
// @todo
|
||||
if (false) {
|
||||
@@ -41,8 +42,6 @@ class Server
|
||||
protected function getDNAttrValues(string $dn,array $attrs=['*','+'],int $deref=LDAP_DEREF_NEVER): ?Entry
|
||||
{
|
||||
try {
|
||||
dump(config('ldap.connections.default.settings'));
|
||||
|
||||
return ($x=(new Adldap)
|
||||
->addProvider(config('ldap.connections.default.settings'))
|
||||
->search()
|
||||
@@ -54,4 +53,27 @@ class Server
|
||||
dd(['e'=>$e]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Query the server for a DN
|
||||
*
|
||||
* @param string $dn
|
||||
* @return |null
|
||||
*/
|
||||
public function query(string $dn)
|
||||
{
|
||||
try {
|
||||
return ($x=(new Adldap)
|
||||
->addProvider(config('ldap.connections.default.settings'))
|
||||
->search()
|
||||
->setBaseDn($dn)
|
||||
//->select($attrs)
|
||||
->listing()
|
||||
->get()) ? $x : NULL;
|
||||
|
||||
// @todo Tidy up this exception
|
||||
} catch (\Exception $e) {
|
||||
dd(['e'=>$e]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -3,7 +3,9 @@
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\Crypt;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
use App\Classes\LDAP\Server;
|
||||
|
||||
@@ -14,17 +16,42 @@ class APIController extends Controller
|
||||
*
|
||||
* @return array|null
|
||||
*/
|
||||
public function bases()
|
||||
public function bases(): Collection
|
||||
{
|
||||
return (new Server())->getBaseDN()->transform(function($item) {
|
||||
return [
|
||||
'title'=>$item,
|
||||
'item'=>base64_encode(Crypt::encryptString($item)),
|
||||
//'folder'=>TRUE,
|
||||
'lazy'=>TRUE,
|
||||
//'key'=>0,
|
||||
//'autoexpand'=>TRUE,
|
||||
];
|
||||
});
|
||||
return (new Server())
|
||||
->getBaseDN()
|
||||
->transform(function($item) {
|
||||
return [
|
||||
'title'=>$item,
|
||||
'item'=>Crypt::encryptString($item),
|
||||
//'folder'=>TRUE,
|
||||
'lazy'=>TRUE,
|
||||
//'key'=>0,
|
||||
//'autoexpand'=>TRUE,
|
||||
];
|
||||
});
|
||||
}
|
||||
|
||||
public function query(Request $request): Collection
|
||||
{
|
||||
$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())
|
||||
->query($dn)
|
||||
->transform(function($item) {
|
||||
//dd($item->getDistinguishedName(),$item);
|
||||
return [
|
||||
'title'=>$item->getDistinguishedName(),
|
||||
'item'=>Crypt::encryptString($item->getDistinguishedName()),
|
||||
//'folder'=>TRUE,
|
||||
'lazy'=>TRUE,
|
||||
//'key'=>0,
|
||||
//'autoexpand'=>TRUE,
|
||||
];
|
||||
});
|
||||
|
||||
Log::debug(sprintf('%s: Query [%s] - Levels [%d]: %s',__METHOD__,$dn,$levels,serialize($x)));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user