473,422 Members | 1,781 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,422 software developers and data experts.

user in domain

How to check if a user is logged into domain ?

Hrcko
Nov 17 '05 #1
2 2482
Hrvoje,

I don't believe that you can do that, since there are many different
ways that a user can be logged on (a user can be logged on to two different
machines), and I don't believe that the domain controller keeps track of
this.

Are you in a controlled environment? Meaning, could you get an app
installed on every machine which will do this for you (you would have to
write a replacement for GINA as well, but I don't know that will intercept
calls to LogonUser though, which could be a problem).

Hope this helps.

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Hrvoje Voda" <hr*********@luatech.com> wrote in message
news:df**********@ss405.t-com.hr...
How to check if a user is logged into domain ?

Hrcko

Nov 17 '05 #2

"Hrvoje Voda" <hr*********@luatech.com> wrote in message
news:df**********@ss405.t-com.hr...
How to check if a user is logged into domain ?

Hrcko


If you want to know wheter the current user is a domain user, you can check
the environment variable USERDOMAIN.

Running XP or higher, you can use System.Management and WMI's class
win32_useraccount.

Here is a sample..

String username = new
WindowsPrincipal(WindowsIdentity.GetCurrent()).Ide ntity.Name;
username = username.Insert(username.IndexOf('\\'), @"\");
// check if current user is a non local account
string queryString = "select Domain from win32_useraccount where
localaccount=false and caption='" + username + "'" ;
using(ManagementObjectSearcher query = new ManagementObjectSearcher( new
SelectQuery(queryString)))
{
foreach( ManagementObject mo in query.Get()) {
Console.WriteLine( "Domain '{0}'", mo["Domain"].ToString());
}
}

If you are looking for the curent interactive logon user(s) things get a bit
more complicated.

Willy.
Nov 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: RobinB | last post by:
We gave created a web application that uses AD for authorization and authentication. The application can be used by domain users as well as the general public. What we currently have is 2 domains...
5
by: Rocky | last post by:
Hi, I have a webform, with 2 textboxs and a submit button. In the text box1, i enter a username and in textbox2 I enter the computer name. Both the username and computer name is in active...
3
by: Dmitry | last post by:
I am trying to figure out how to pass set of credentials to System.IO Challenge is: App is running under one set of credentials, but via GUI user have a chance to enter another set. I would like...
18
by: Arthur | last post by:
Hi All, I would like to get the name of the user given their networkID, is this something Active Directory would be useful for?(For intranet users) If so, can you please point me to some sample...
6
by: Not Me | last post by:
Hey, We have an sql server 2000 machine and IIS 6 machine running seperately but on the same domain. I can connect fine to the database without using impersonation, but when it's enabled I get...
2
by: Fox1977 | last post by:
Hi folks, Just wondering if anyone can help me out with this problem I'm having getting a particular .net web application to run on a windows 2003 r2 x64 platform running as a domain account. ...
1
by: =?Utf-8?B?Qi5BaGxzdGVkdA==?= | last post by:
Hi all, This is something that I have been toying with for about a week now. What I want to achieve is Install a Service with Customised parameters (using InstallUtil.exe) for User Name. Example...
2
by: Jim in Arizona | last post by:
I'm trying to do a check to see if a specific active directory user account exists in active directory AND a specific group. I can't seem to get the filter down right. I can do this to find a...
4
by: =?Utf-8?B?QXZhRGV2?= | last post by:
ASP.Net 2. We are migrating to Windows 2008 64 bit Server with IIS 7 from Windows 2003 32 Bit with IIS 6. A few library classes we wrote uses impersonation in code like explained in this...
4
by: =?Utf-8?B?WmFyYm9yZw==?= | last post by:
I'm writing a little program that will run when a user logs in, checks their password expiration and also installs a piece of monitoring software if necessary. The program has to run on Vista so I...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.