Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / March 2006

Tip: Looking for answers? Try searching our database.

Get current logged on user

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Niclas - 28 Feb 2006 22:39 GMT
Is it possible to configure a Windows Service to:

1. Start the service when a user logs on (i.e. service not active before
logon)

2. Determine the WindowsIdentity of the currently logged on user

Niclas
Greg Young - 28 Feb 2006 23:14 GMT
I have dealt with a similar situation before ... I never got the actual
identity of the user but using

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/termserv/TermSe
rv/wtsgetactiveconsolesessionid.asp

an
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/termserv/TermSe
rv/wtsquerysessioninformation.asp


I was able to get the name of the user (including fast switching for
multiple users).

Cheers,

Greg

> Is it possible to configure a Windows Service to:
>
[quoted text clipped - 4 lines]
>
> Niclas
Gabriel Magaña - 28 Feb 2006 23:33 GMT
Did you take into account remote desktop and/or terminal services?  This
would mean that several users have valid session concurrently...  How did
you deal with that screnario?

>I have dealt with a similar situation before ... I never got the actual
> identity of the user but using
[quoted text clipped - 18 lines]
>>
>> Niclas
William Stacey [MVP] - 01 Mar 2006 02:44 GMT
| 1. Start the service when a user logs on (i.e. service not active before
| logon)

You could use the ServiceControl control to start service when your app
starts. Or put your app in the Startup folder.

| 2. Determine the WindowsIdentity of the currently logged on user

private void button18_Click(object sender, EventArgs e)

{

   WindowsIdentity wi = WindowsIdentity.GetCurrent();

   Console.WriteLine("Current User: " + wi.Name);

   foreach (IdentityReference ir in wi.Groups)

   {

       NTAccount acc = (NTAccount)ir.Translate(typeof(NTAccount));

       Console.WriteLine("Member of: " + acc.Value);

   }

}

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.