Search code examples
.netldapwindowsdomainaccount

How do you transform a upn name to a login name?


How do you transform a upn name like "user@example.com" to the corresponding NT account name, which is frequently "EXAMPLE\user"? In the domains I'm familiar with, I can take the first part after the '@' sign, but I'm concerned that this is not guaranteed to be correct. Do I have to run an ldap query? Would it be a property on the user's DirectoryEntry if I did?

I'm trying to do this in C#, but I'd welcome any pointers or corrections to my terminology.

Thanks


Solution

  • I ended up using p-invoke to call DsCrackNames, rather than using the COM interface Mischa suggested (which I understand is a wrapper around the same function).