Skip to content

Commit da7e88e

Browse files
committed
Enable getDNSecure to include a command, that is encrypted with the DN
1 parent dc2f3f3 commit da7e88e

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

app/Ldap/Entry.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,10 @@ public function getSortKeyAttribute(): string
144144

145145
public function addAttribute(string $key,mixed $value): void
146146
{
147+
// While $value is mixed, it can only be a string
148+
if (! is_string($value))
149+
throw new \Exception('value should be a string');
150+
147151
$key = $this->normalizeAttributeKey($key);
148152

149153
if (! config('server')->schema('attributetypes')->has($key))
@@ -239,11 +243,12 @@ public function getAvailableAttributes(): Collection
239243

240244
/**
241245
* Return a secure version of the DN
246+
* @param string $cmd
242247
* @return string
243248
*/
244-
public function getDNSecure(): string
249+
public function getDNSecure(string $cmd=''): string
245250
{
246-
return Crypt::encryptString($this->getDn());
251+
return Crypt::encryptString(($cmd ? sprintf('*%s|',$cmd) : '').$this->getDn());
247252
}
248253

249254
/**

0 commit comments

Comments
 (0)