nur-sery/nur_src/ldap/app/TLdapApplication.php

35 lines
853 B
PHP

<?php
namespace nur\ldap\app;
use nur\A;
use nur\ldap\LdapConn;
trait TLdapApplication {
protected $config;
protected $uri, $binddn, $password;
protected function fixConfig(?string &$config): void {
}
function getConn(?array $supplParams=null): LdapConn {
$config = $this->config;
$this->fixConfig($config);
$loadParams = static::LOAD_PARAMS;
$autoconnect = $autofillParams = null;
if ($config === null) {
$params = [];
} else {
$params = require $config;
if (!$loadParams) $autoconnect = $autofillParams = false;
}
A::merge($params, A::filter_n([
"uri" => $this->uri,
"binddn" => $this->binddn,
"password" => $this->password,
"autoconnect" => $autoconnect,
"autofill_params" => $autofillParams,
]), $supplParams);
return new LdapConn($params);
}
}