Hi all,
I need to get a list of all in-use (not all possible) computer names and their current logged on users on a local network.
I have tried the following code.
PrincipalContext ctx = new PrincipalContext(ContextType.Domain);
IPAddress[] ip = Dns.GetHostAddresses(ctx.ConnectedServer.Split('.').GetValue(0).ToString());
DirectoryEntry dirEn = new DirectoryEntry(String.Format("LDAP://" + ip[0] + " x.y.com","DC=x,DC=y, DC=com"));
DirectorySearcher dirSearcher = new DirectorySearcher(dirEn);
SearchResultCollection result;
dirSearcher.Filter="(&(ObjectClass=computer))";
result = dirSearcher.FindAll();
It returns list of all computers in my network but i want list of only logged on computers(I mean which computers that users are logging in and using them right now).