Skip to content

Commit

Permalink
Fix authentication with DirectoryEntry (#89)
Browse files Browse the repository at this point in the history
  • Loading branch information
nurfed1 authored Jan 19, 2024
1 parent 94a8306 commit 4988061
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions src/CommonLib/LDAPUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1702,18 +1702,30 @@ private class ResolvedWellKnownPrincipal

public string GetConfigurationPath(string domainName = null)
{
var rootDse = domainName == null
? new DirectoryEntry("LDAP://RootDSE")
: new DirectoryEntry($"LDAP://{NormalizeDomainName(domainName)}/RootDSE");
string path = domainName == null
? "LDAP://RootDSE"
: $"LDAP://{NormalizeDomainName(domainName)}/RootDSE";

DirectoryEntry rootDse;
if (_ldapConfig.Username != null)
rootDse = new DirectoryEntry(path, _ldapConfig.Username, _ldapConfig.Password);
else
rootDse = new DirectoryEntry(path);

return $"{rootDse.Properties["configurationNamingContext"]?[0]}";
}

public string GetSchemaPath(string domainName)
{
var rootDse = domainName == null
? new DirectoryEntry("LDAP://RootDSE")
: new DirectoryEntry($"LDAP://{NormalizeDomainName(domainName)}/RootDSE");
string path = domainName == null
? "LDAP://RootDSE"
: $"LDAP://{NormalizeDomainName(domainName)}/RootDSE";

DirectoryEntry rootDse;
if (_ldapConfig.Username != null)
rootDse = new DirectoryEntry(path, _ldapConfig.Username, _ldapConfig.Password);
else
rootDse = new DirectoryEntry(path);

return $"{rootDse.Properties["schemaNamingContext"]?[0]}";
}
Expand Down

0 comments on commit 4988061

Please sign in to comment.