TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Melanie Peterson
NA
7
0
Identifying remote users using WMI
Jul 23 2009 2:37 PM
Hi - I have some VB code that I'm trying to translate to c#. The code has a few WMI calls in it, and I'm stuck. Specifically, my VB code has the following: 'identify remote sessions Dim strComputer As String = "." Dim objWMIService As Object = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") Dim colSessions As Object = objWMIService.ExecQuery("Select * from Win32_LogonSession Where LogonType = 10") 'loop through results and get logged on userid Dim objSession As Object For Each objSession In colSessions Dim colList As Object colList = objWMIService.ExecQuery("Associators of " & "{Win32_LogonSession.LogonId=" & objSession.LogonId & "} " & "Where AssocClass=Win32_LoggedOnUser Role=Dependent") Dim objItem As Object For Each objItem In colList 'look for match with current user (Session["UserEID"] as id'd by 'Windows Authentication in Global.asax If objItem.Name = Session["UserEID"] Then etc etc The c# equivalent to get remote sessions is ManagementObjectSearcher searcher = new ManagementObjectSearcher("root\\CIMV2", "SELECT * FROM Win32_LogonSession WHERE LogonType = 10"); foreach (ManagementObject queryObj in searcher.Get()) etc etc but then how do I drill down in my remote sessions to find the Name property from the Win32_LoggedOnUser class? Of course, if anyone knows of another way to do this, that would be fine, too, doesn't have to be via WMI. Thanks!
Reply
Answers (
0
)
chat server
Process Exits Unexpectdly