Re: How to retrieve user's domain correctly?
From: WNC (wcedeno_at_online.nospam)
Date: 09/17/04
- Next message: Drebin: "Re: How to retrieve user's domain correctly?"
- Previous message: news.microsoft.com: "Re: search in a HashTable, DataTable, and XmlDocument, which is faster?"
- In reply to: Drebin: "Re: How to retrieve user's domain correctly?"
- Next in thread: Drebin: "Re: How to retrieve user's domain correctly?"
- Reply: Drebin: "Re: How to retrieve user's domain correctly?"
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 17 Sep 2004 05:59:06 -0700
Thank you Drebin for your response.
We have checked this multiple times and we are certain that we have
logged-in through the domain (USERX_DOMAIN). We used another system which
does not have the local USERX account and we get the correct information.
We investigated further this bug and found that even a WIN32 API returns the
incorrect information. Following is the summary of what we have seen so far.
All of the results were obtained from a system running .Net framework 1.1 on
Windows 2000 profesional SP4.
1. .Net System.Environment.UserDomainName -> Incorrectly returns MACHINE_NAME.
2. .Net SystemInformation.UserDomainName -> Incorrectly returns MACHINE_NAME.
3. Win32 API LookupAccountName -> Incorrectly returns MACHINE_NAME.
4. .Net System.Environment.GetEnvironmentVariable("USERDOMAIN") -> Correctly
returns USERX_DOMAIN.
5. Win32 API GetUserNameEx with NAME_FORMAT set to -> Correctly returns
USERX_DOMAIN/USERX.
At this moment it looks that the problem is being propagated to the .Net
framework classes by the Win32 API.
WNC
"Drebin" wrote:
> It sounds like you authenticated through your local machine - in other
> words, when you go to login, you specify to log in from the local machine
> instead of the domain.
>
> If that is the case, this is correct - you ARE logged in as your machine
> account and NOT your domain account. And if you are trying to get the
> running user of the CURRENT process, this is pretty reliable:
>
> string strUser = Environment.UserDomainName + "\\" + Environment.UserName;
>
> HTH
>
>
> "WNC" <wcedeno@online.nospam> wrote in message
> news:0DAE4440-A1C9-4BF8-8EC9-D91E0869FE9C@microsoft.com...
> > If you are using any of the following two calls below, you may not get
> > what
> > you are looking for.
> >
> > string domain = System.Environment.UserDomainName;
> > string domain = SystemInformation.UserDomainName;
> >
> > I happen to have an account USERX as part of the local domain
> > (MACHINE_NAME)
> > of my system. The same account name USERX is used for my USERX_DOMAIN
> > domain.
> > I logged in as USERX_DOMAIN\USERX but the domain returned by those two
> > calls
> > is MACHINE_NAME.
> >
> > As a workaround, I am going to use the value of the environment variable
> > USERDOMAIN, which is correct, to get the correct domain name. How could I
> > obtain the correct domain name without depending on an overwritable
> > environment variable?
> >
> > --
> > WNC
>
>
>
- Next message: Drebin: "Re: How to retrieve user's domain correctly?"
- Previous message: news.microsoft.com: "Re: search in a HashTable, DataTable, and XmlDocument, which is faster?"
- In reply to: Drebin: "Re: How to retrieve user's domain correctly?"
- Next in thread: Drebin: "Re: How to retrieve user's domain correctly?"
- Reply: Drebin: "Re: How to retrieve user's domain correctly?"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|