windows-principal

How to create WindowsIdentity/WindowsPrincipal from username in DOMAIN\user format

让人想犯罪 __ 提交于 2019-11-26 21:11:53
问题 The WindowsIdentity(string) constructor requires the username to be in username@domain.com format. But in my case I get the usernames from a DB in the old DOMAIN\user format (and then have to check their Windows role membership). What is the best way of creating WindowsPrincipal from the old style (sAMAccountName) username? 回答1: It does seem that there is no way of converting the username format without involving a query to Active Directory. Since that is the case there is no need to create