Re: How to retrieve user's domain correctly?
From: WNC (wcedeno_at_online.nospam)
Date: 09/17/04
- Next message: Jon Skeet [C# MVP]: "Re: ?RE: Could events ever ?overrun? ?or otherwise be missed by a hand?ler?"
- Previous message: Paolo Liverani: "error handler dumping local variables"
- 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?"
- Reply: Nick Malik: "Re: How to retrieve user's domain correctly?"
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 17 Sep 2004 06:59:02 -0700
Your statement is incorrect. The OS will not blindly change the domain
because the local account name happens to match the domain account name. The
two accounts are independent and are treated as such. I will be interested in
a reference from MS describing your logic below.
The application should be able to obtain the domain, used by the logged-in
user, correctly. The different results obtained by the methods described
previously points to a bug somewhere.
"Drebin" wrote:
> If you DO have a matching account on your local machine, that is expected
> behaviour - your local account is much more "trusted" than your domain
> account, and likely has more privs on the local machine. So it is by design
> that if you have a domain and matching local account, the local account
> should always take precendence. In other words, your process will always try
> your local SID first, when trying to do anything, including trying to find
> out where the account is from.
>
> If you have a machine that does NOT have a matching account - it should,
> work the way you expected, because there is only one instance of that
> account. If THAT shows incorrectly, then I would say it's a bona fide bug in
> Win32
>
>
> "WNC" <wcedeno@online.nospam> wrote in message
> news:F19F4742-6B18-47FE-A7D2-5D6DACEC0DD1@microsoft.com...
> > 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: Jon Skeet [C# MVP]: "Re: ?RE: Could events ever ?overrun? ?or otherwise be missed by a hand?ler?"
- Previous message: Paolo Liverani: "error handler dumping local variables"
- 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?"
- Reply: Nick Malik: "Re: How to retrieve user's domain correctly?"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|