1
votes

Assume there is Active Directory domain: "chiled.root.f1dm.com"

Netbios name: "CHILED1F1"

Given this code:

if (HttpContext.Current == null || HttpContext.Current.User == null ||
            !HttpContext.Current.User.Identity.IsAuthenticated)
        {
            throw new MyException(WRONG_USERNAME_OR_PASSWORD_ERROR_CODE, WRONG_USERNAME_OR_PASSWORD_ERROR_MESSAGE);
        }

I'm looking for a way to reach from the HttpContext the user's Fully qualified domain name (FQDN). Currently I'm getting from the context the user's domain in the Netbios form (Like: CHILED1F1\user_name) but I need this: chiled.root.f1dm.com\user_name

I there a way to do it? I need it for the Windows current user only (So the Machine's domain name will not help me). Thanks!

1
Your HTTP Context is not intrinsically connected to Active Directory. I dont believe there is any way to obtain what you are looking for from the HTTP Context. The only possible way would be to look at what Type you are actually getting on the Current User. if the actual implementation of the user extends the data you are looking for it may be possible. - Theo

1 Answers

0
votes

If your user as logged in his using AD, you can try to get his name via ServerVariables. Exemple:

string username = Request.ServerVariables["AUTH_USER"].ToString();