I wish to obtain the domain SID from a user account that has been used to access my web page, but…
In some instances, you dont have access to the HttpContext object to call HttpContext.Current.Request.LogonUserIdentity.User.Value
All the static function is able to accept is a user-name as a string, and a domain-name as a string.
If the domain is left blank, it is amused that the user account name is within the same domain as the IIS server that the process is executing upon. :/
your help would be most appreciated as always.
Cheers.
To get the a user’s domain, you can use LookupAccountName. In case you need a pinvoke sample, get it from pinvoke.net
You pass in
DOMAIN\UserNameto the function. TheLookupAccountNamefunction will give you back the user SID and the domain name.I suspect that you don’t really need to know the domain SID. I would think the returned domain name should be enough for you. If you really want to know the domain SID, you can extract it directly from a the returned user SID.
A user SID is always starting with a domain SID. For the details of how a SID structure looks like and how to extract the domain SID, please check here