mirror of
https://gitlab.easter-eggs.com/ee/ldapsaisie.git
synced 2024-11-22 09:59:06 +01:00
Add getRdn() and parentDn() helper functions
This commit is contained in:
parent
1825ce429e
commit
d387052068
1 changed files with 29 additions and 0 deletions
|
@ -405,6 +405,35 @@ function sumDn($dn1,$dn2) {
|
|||
return $basedn;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract and retreive RDN from DN
|
||||
* @param string $dn
|
||||
* @param bool $with_attr If true, include the RDN attribute name (optional, default: true)
|
||||
* @return string|null|false The parent object DN, null if no parent or false in case of error
|
||||
*/
|
||||
function getRdn($dn, $with_attr=true) {
|
||||
$parts = ldap_explode_dn($dn, 0);
|
||||
if (!is_array($parts) || !isset($parts['count'])) return false;
|
||||
if ($with_attr)
|
||||
return $parts[0];
|
||||
$equal_pos = strpos($parts[0], '=');
|
||||
if ($equal_pos !== false)
|
||||
return substr($parts[0], $equal_pos+1);
|
||||
return $parts[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* Retreive parent object DN
|
||||
* @param string $dn
|
||||
* @return string|null|false The parent object DN, null if no parent or false in case of error
|
||||
*/
|
||||
function parentDn($dn) {
|
||||
$parts = ldap_explode_dn($dn, 0);
|
||||
if (!is_array($parts) || !isset($parts['count'])) return false;
|
||||
if ($parts['count'] == 1) return null;
|
||||
return implode(',', array_slice($parts, 2));
|
||||
}
|
||||
|
||||
function checkEmail($value,$domain=NULL,$checkDns=true) {
|
||||
$log = LSlog :: get_logger('checkEmail');
|
||||
$regex = '/^((\"[^\"\f\n\r\t\v\b]+\")|([\w\!\#\$\%\&\'\*\+\-\~\/\^\`\|\{\}]+(\.[\w\!\#\$\%\&\'\*\+\-\~\/\^\`\|\{\}]+)*))@((\[(((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9])))\])|(((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9])))|((([A-Za-z0-9\-])+\.)+[A-Za-z\-]+))$/';
|
||||
|
|
Loading…
Reference in a new issue