From da7e88e834a0a23fa9ded6c53605ffc0d073fec2 Mon Sep 17 00:00:00 2001 From: Deon George Date: Sat, 1 Mar 2025 19:56:56 +1100 Subject: [PATCH] Enable getDNSecure to include a command, that is encrypted with the DN --- app/Ldap/Entry.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/app/Ldap/Entry.php b/app/Ldap/Entry.php index cb25f6b9..b52a3617 100644 --- a/app/Ldap/Entry.php +++ b/app/Ldap/Entry.php @@ -144,6 +144,10 @@ class Entry extends Model public function addAttribute(string $key,mixed $value): void { + // While $value is mixed, it can only be a string + if (! is_string($value)) + throw new \Exception('value should be a string'); + $key = $this->normalizeAttributeKey($key); if (! config('server')->schema('attributetypes')->has($key)) @@ -239,11 +243,12 @@ class Entry extends Model /** * Return a secure version of the DN + * @param string $cmd * @return string */ - public function getDNSecure(): string + public function getDNSecure(string $cmd=''): string { - return Crypt::encryptString($this->getDn()); + return Crypt::encryptString(($cmd ? sprintf('*%s|',$cmd) : '').$this->getDn()); } /**