Resolved #18: GetAccountByUPN

This commit is contained in:
MichaelGrafnetter 2016-06-21 09:27:40 +02:00
parent 6640562faf
commit 0406d0c024
3 changed files with 14 additions and 0 deletions

View File

@ -280,6 +280,12 @@ namespace DSInternals
return Guid::Parse(stringGuid);
}
Guid DrsConnection::ResolveGuid(String^ userPrincipalName)
{
auto stringGuid = this->ResolveName(userPrincipalName, DS_NAME_FORMAT::DS_USER_PRINCIPAL_NAME, DS_NAME_FORMAT::DS_UNIQUE_ID_NAME);
return Guid::Parse(stringGuid);
}
String^ DrsConnection::ResolveName(String^ name, DS_NAME_FORMAT formatOffered, DS_NAME_FORMAT formatDesired)
{
// We only want to resolve 1 name at a time:

View File

@ -49,6 +49,7 @@ namespace DSInternals
String^ ResolveDistinguishedName(SecurityIdentifier^ objectSid);
Guid ResolveGuid(NTAccount^ accountName);
Guid ResolveGuid(SecurityIdentifier^ objectSid);
Guid ResolveGuid(String^ userPrincipalName);
protected:
virtual bool ReleaseHandle() override;
private:

View File

@ -129,6 +129,13 @@
return this.GetAccount(objectGuid);
}
public DSAccount GetAccountByUPN(string userPrincipalName)
{
// TODO: Redesign the GetAccount overloads, for GetAccountByUPN to follow the same convention.
Guid objectGuid = this.drsConnection.ResolveGuid(userPrincipalName);
return this.GetAccount(objectGuid);
}
private DirectorySecretDecryptor SecretDecryptor
{
get