Updated server info
This commit is contained in:
@@ -2,20 +2,24 @@
|
||||
|
||||
namespace App\Classes\LDAP;
|
||||
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
/**
|
||||
* Represents an attribute of an LDAP Object
|
||||
*/
|
||||
class Attribute
|
||||
{
|
||||
# Attribute Name
|
||||
public string $name;
|
||||
// Attribute Name
|
||||
protected string $name;
|
||||
|
||||
/*
|
||||
# Source of this attribute definition
|
||||
protected $source;
|
||||
*/
|
||||
|
||||
# Current and Old Values
|
||||
protected array $values;
|
||||
// Current and Old Values
|
||||
protected Collection $values;
|
||||
|
||||
/*
|
||||
protected $oldvalues = array();
|
||||
|
||||
@@ -76,9 +80,10 @@ class Attribute
|
||||
protected $postvalue = array();
|
||||
*/
|
||||
|
||||
public function __construct(string $name,array $values) {
|
||||
public function __construct(string $name,array $values)
|
||||
{
|
||||
$this->name = $name;
|
||||
$this->values = $values;
|
||||
$this->values = collect($values);
|
||||
|
||||
/*
|
||||
# Should this attribute be hidden
|
||||
@@ -102,7 +107,7 @@ class Attribute
|
||||
*/
|
||||
public function __toString(): string
|
||||
{
|
||||
return join('<br>',$this->values);
|
||||
return $this->values->join('<br>');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -20,7 +20,11 @@ class Factory
|
||||
* Map of attributes to appropriate class
|
||||
*/
|
||||
public const map = [
|
||||
'jpegphoto'=>Attribute\Binary\JpegPhoto::class,
|
||||
'jpegphoto' => Binary\JpegPhoto::class,
|
||||
'supportedcontrol' => OID::class,
|
||||
'supportedextension' => OID::class,
|
||||
'supportedfeatures' => OID::class,
|
||||
'supportedsaslmechanisms' => Mechanisms::class,
|
||||
];
|
||||
|
||||
/**
|
||||
|
80
app/Classes/LDAP/Attribute/Mechanisms.php
Normal file
80
app/Classes/LDAP/Attribute/Mechanisms.php
Normal file
@@ -0,0 +1,80 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\LDAP\Attribute;
|
||||
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
|
||||
use App\Classes\LDAP\Attribute;
|
||||
|
||||
/**
|
||||
* Represents an attribute whose values are binary
|
||||
*/
|
||||
class Mechanisms extends Attribute
|
||||
{
|
||||
public function __toString(): string
|
||||
{
|
||||
return $this->values
|
||||
->transform(function($item) {
|
||||
$format = sprintf('<abbr class="pb-1" title="%s"><i class="fas fa-book pr-2"></i>%s</abbr>%s<p class="mb-0">%s</p>',
|
||||
$item,
|
||||
static::get($item,'title'),
|
||||
($x=static::get($item,'ref')) ? sprintf('<abbr class="pl-2" title="%s"><i class="fas fa-comment-dots"></i></abbr>',$x) : '',
|
||||
static::get($item,'desc'),
|
||||
);
|
||||
|
||||
return $format;
|
||||
})->join('<br>');
|
||||
}
|
||||
|
||||
/**
|
||||
* Given an SASL Mechanism name, returns a verbose description of the Mechanism.
|
||||
* This function parses ldap_supported_saslmechanisms.txt and looks up the specified
|
||||
* Mechanism, and returns the verbose message defined in that file.
|
||||
*
|
||||
* <code>
|
||||
* "SCRAM-SHA-1" => array:3 [▼
|
||||
* "title" => "Salted Challenge Response Authentication Mechanism (SCRAM) SHA1"
|
||||
* "ref" => "RFC 5802"
|
||||
* "desc" => "This specification describes a family of authentication mechanisms called the Salted Challenge Response Authentication Mechanism (SCRAM) which addresses the req ▶"
|
||||
* ]
|
||||
* </code>
|
||||
*
|
||||
* @param string $string The SASL Mechanism (ie, "SCRAM-SHA-1") of interest.
|
||||
* @param string $key The title|ref|desc to return
|
||||
* @return string|NULL
|
||||
*/
|
||||
private static function get(string $string,string $key): ?string
|
||||
{
|
||||
$array = Cache::remember('saslmechanisms',86400,function() {
|
||||
try {
|
||||
$f = fopen(config_path('ldap_supported_saslmechanisms.txt'),'r');
|
||||
|
||||
} catch (\Exception $e) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
$result = collect();
|
||||
|
||||
while (! feof($f)) {
|
||||
$line = trim(fgets($f));
|
||||
|
||||
if (! $line OR preg_match('/^#/',$line))
|
||||
continue;
|
||||
|
||||
$fields = explode(':',$line);
|
||||
|
||||
$result->put($x=Arr::get($fields,0),[
|
||||
'title'=>Arr::get($fields,1,$x),
|
||||
'ref'=>Arr::get($fields,2),
|
||||
'desc'=>Arr::get($fields,3,__('No description available, can you help with one?')),
|
||||
]);
|
||||
}
|
||||
fclose($f);
|
||||
|
||||
return $result;
|
||||
});
|
||||
|
||||
return Arr::get(($array ? $array->get($string) : []),$key);
|
||||
}
|
||||
}
|
85
app/Classes/LDAP/Attribute/OID.php
Normal file
85
app/Classes/LDAP/Attribute/OID.php
Normal file
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\LDAP\Attribute;
|
||||
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
|
||||
use App\Classes\LDAP\Attribute;
|
||||
|
||||
/**
|
||||
* Represents an attribute whose values are binary
|
||||
*/
|
||||
class OID extends Attribute
|
||||
{
|
||||
public function __toString(): string
|
||||
{
|
||||
return $this->values
|
||||
->transform(function($item) {
|
||||
if (preg_match('/[0-9]+\.[0-9]+\.[0-9]+/',$item)) {
|
||||
$format = sprintf('<abbr class="pb-1" title="%s"><i class="fas fa-list-ol pr-2"></i>%s</abbr>%s<p class="mb-0">%s</p>',
|
||||
$item,
|
||||
static::get($item,'title'),
|
||||
($x=static::get($item,'ref')) ? sprintf('<abbr class="pl-2" title="%s"><i class="fas fa-comment-dots"></i></abbr>',$x) : '',
|
||||
static::get($item,'desc'),
|
||||
);
|
||||
|
||||
return $format;
|
||||
|
||||
} else
|
||||
return $item;
|
||||
})->join('<br>');
|
||||
}
|
||||
|
||||
/**
|
||||
* Given an LDAP OID number, returns a verbose description of the OID.
|
||||
* This function parses ldap_supported_oids.txt and looks up the specified
|
||||
* OID, and returns the verbose message defined in that file.
|
||||
*
|
||||
* <code>
|
||||
* "1.3.6.1.4.1.4203.1.5.1" => array:3 [
|
||||
* [title] => All Operational Attribute
|
||||
* [ref] => RFC 3673
|
||||
* [desc] => An LDAP extension which clients may use to request the return of all operational attributes.
|
||||
* ]
|
||||
* </code>
|
||||
*
|
||||
* @param string $oid The OID number (ie, "1.3.6.1.4.1.4203.1.5.1") of the OID of interest.
|
||||
* @param string $key The title|ref|desc to return
|
||||
* @return string|null
|
||||
* @testedby TranslateOidTest::testRootDSE()
|
||||
*/
|
||||
private static function get(string $string,string $key): ?string
|
||||
{
|
||||
$array = Cache::remember('oids',86400,function() {
|
||||
try {
|
||||
$f = fopen(config_path('ldap_supported_oids.txt'),'r');
|
||||
|
||||
} catch (\Exception $e) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
$result = collect();
|
||||
|
||||
while (! feof($f)) {
|
||||
$line = trim(fgets($f));
|
||||
|
||||
if (! $line OR preg_match('/^#/',$line))
|
||||
continue;
|
||||
|
||||
$fields = explode(':',$line);
|
||||
|
||||
$result->put($x=Arr::get($fields,0),[
|
||||
'title'=>Arr::get($fields,1,$x),
|
||||
'ref'=>Arr::get($fields,2),
|
||||
'desc'=>Arr::get($fields,3,__('No description available, can you help with one?')),
|
||||
]);
|
||||
}
|
||||
fclose($f);
|
||||
|
||||
return $result;
|
||||
});
|
||||
|
||||
return Arr::get(($array ? $array->get($string) : []),$key);
|
||||
}
|
||||
}
|
@@ -255,62 +255,6 @@ class Server
|
||||
->find($dn)) ? $x : NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Given an LDAP OID number, returns a verbose description of the OID.
|
||||
* This function parses ldap_supported_oids.txt and looks up the specified
|
||||
* OID, and returns the verbose message defined in that file.
|
||||
*
|
||||
* <code>
|
||||
* Array (
|
||||
* [title] => All Operational Attribute
|
||||
* [ref] => RFC 3673
|
||||
* [desc] => An LDAP extension which clients may use to request the return of all operational attributes.
|
||||
* )
|
||||
* </code>
|
||||
*
|
||||
* @param string $oid The OID number (ie, "1.3.6.1.4.1.4203.1.5.1") of the OID of interest.
|
||||
* @param string $key The title|ref|desc to return
|
||||
* @return string|null
|
||||
* @testedby TranslateOidTest::testRootDSE()
|
||||
*/
|
||||
public static function getOID(string $oid,string $key): ?string
|
||||
{
|
||||
$oids = Cache::remember('oids',86400,function() {
|
||||
try {
|
||||
$f = fopen(config_path('ldap_supported_oids.txt'),'r');
|
||||
|
||||
} catch (Exception $e) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
$result = collect();
|
||||
|
||||
while (! feof($f)) {
|
||||
$line = trim(fgets($f));
|
||||
|
||||
if (! $line OR preg_match('/^#/',$line))
|
||||
continue;
|
||||
|
||||
$fields = explode(':',$line);
|
||||
|
||||
$result->put(Arr::get($fields,0),[
|
||||
'title'=>Arr::get($fields,1),
|
||||
'ref'=>Arr::get($fields,2),
|
||||
'desc'=>Arr::get($fields,3),
|
||||
]);
|
||||
}
|
||||
fclose($f);
|
||||
|
||||
return $result;
|
||||
});
|
||||
|
||||
return Arr::get(
|
||||
($oids ? $oids->get($oid) : []),
|
||||
$key,
|
||||
($key == 'desc' ? 'No description available, can you help with one?' : ($key == 'title' ? $oid : NULL))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* This function determines if the specified attribute is contained in the force_may list
|
||||
* as configured in config.php.
|
||||
|
Reference in New Issue
Block a user