A
Arshad Parvez
Hi,
My OS is Windows XP without any network, nor Active Directory. There
are only a few local users. I am trying to list all my local users in
a list box. Here is my code:
string strMachine;
strMachine = String.Format("WinNT://{0}", Environment.MachineName);
DirectoryEntry allUsers = new DirectoryEntry(strMachine);
foreach (DirectoryEntry user in allUsers.Children)
{
lstUsers.Items.Add(user.Name);
}
Though it doesn't generate any errors, there is a problem. I get a
long list of about 100 items which includes internal users like
ASPNet, HelpAssistant and even explorer. I have tried with appending
<<<",group">>> at the end of machine name but in that case it gives
error in <<<foreach...>>> line. I tried Directory Searcher but that
too generates Unknown Runtime Error when doing searcher.FindOne() or
searcher.FindAll(). I have tried so many examples from the web/groups
- none works.
Please help me with this.
Arshad
My OS is Windows XP without any network, nor Active Directory. There
are only a few local users. I am trying to list all my local users in
a list box. Here is my code:
string strMachine;
strMachine = String.Format("WinNT://{0}", Environment.MachineName);
DirectoryEntry allUsers = new DirectoryEntry(strMachine);
foreach (DirectoryEntry user in allUsers.Children)
{
lstUsers.Items.Add(user.Name);
}
Though it doesn't generate any errors, there is a problem. I get a
long list of about 100 items which includes internal users like
ASPNet, HelpAssistant and even explorer. I have tried with appending
<<<",group">>> at the end of machine name but in that case it gives
error in <<<foreach...>>> line. I tried Directory Searcher but that
too generates Unknown Runtime Error when doing searcher.FindOne() or
searcher.FindAll(). I have tried so many examples from the web/groups
- none works.
Please help me with this.
Arshad