Skip to content

Commit 18175ba

Browse files
authored
rewrite update-ldap-cache.php (#157)
* rewrite update-ldap-cache.php fix style fix style fix style * add gecos * add gecos * remove extra gecos * phpcs
1 parent 8b2264c commit 18175ba

File tree

4 files changed

+1417
-66
lines changed

4 files changed

+1417
-66
lines changed

resources/lib/UnityLDAP.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,4 +340,35 @@ public function getOrgGroupEntry($gid)
340340
$gid = ldap_escape($gid, LDAP_ESCAPE_DN);
341341
return $this->getEntry(unityLDAP::RDN . "=$gid," . $this->STR_ORGGROUPOU);
342342
}
343+
344+
public static function parseUserChildrenArray(array $userChildrenArray): array
345+
{
346+
// input comes from LdapEntry::getChildrenArray on a UnityUser
347+
$output = [];
348+
$required_string_attributes = [
349+
"gidnumber",
350+
"givenname",
351+
"homedirectory",
352+
"loginshell",
353+
"mail",
354+
"o",
355+
"sn",
356+
"uid",
357+
"uidnumber",
358+
"gecos",
359+
];
360+
foreach ($required_string_attributes as $key) {
361+
$output[$key] = $userChildrenArray[$key][0];
362+
}
363+
$output["firstname"] = $output["givenname"];
364+
$output["lastname"] = $output["sn"];
365+
$output["org"] = $output["o"];
366+
$output["objectclass"] = $userChildrenArray["objectclass"];
367+
if (array_key_exists("sspublickey", $userChildrenArray)) {
368+
$output["sshpublickey"] = $userChildrenArray["sshpublickey"];
369+
} else {
370+
$output["sshpublickey"] = [];
371+
}
372+
return $output;
373+
}
343374
}

resources/lib/UnityRedis.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,4 +95,9 @@ public function removeCacheArray($object, $key, $value)
9595
$this->setCache($object, $key, $cached_val);
9696
}
9797
}
98+
99+
public function flushAll()
100+
{
101+
$this->client->flushAll();
102+
}
98103
}

0 commit comments

Comments
 (0)