mattjohnsonpint/SimpleImpersonation

Specifying username in UPN syntax?

mrichman opened this issue · 2 comments

Is it possible to get an overload to pass a username in UPN syntax (i.e. username@domain.local) instead of the SAM name (i.e. DOMAIN\username)?

using (Impersonation.LogonUser(upn, password, LogonType.Interactive))
{ ... }

I'm starting to use Windows 2016 domain controllers and servers, and I can't guarantee there will be a SAM-compatible name forever.

I think I just answered my own question.

https://msdn.microsoft.com/en-us/library/windows/desktop/aa378184(v=vs.85).aspx

"If you use the user principal name (UPN) format, User@DNSDomainName, the lpszDomain parameter must be NULL"

Cool. Thanks for sharing!