M
MP
Hello,
I am writting an application that requires to list all users in our domain,
the code is below. My application is written in C# 2.0. I enumerate all
users fine with my code, except that when I exit the application normally I
get a popup from MS-DEV saying "There is no source code available for the
current location."
After I click ok I get "InvalidComObjectException was unhandled", "COM
object that has been separated from its underlying RCW can not be used".
Here is my code. I have a similar behavior when I try to enumerate the
domains on our network.
Can someone help me on this one? I have no idea where to look.
Thank you!
Martin
private bool GetDomainUsers()
{
try
{
// Start from the root of the active active directory
DirectoryEntry domainRoot = new DirectoryEntry(LDAP://MyDomain);
DirectorySearcher domainSearch = new DirectorySearcher(domainRoot);
// Set the search filter.
domainSearch.Filter =
("(&(objectCategory=person)(objectClass=user))");
domainSearch.PageSize = 100;
// Perform the search
SearchResultCollection usersFound = domainSearch.FindAll();
// Enumerate over each returned domain.
foreach (SearchResult searchResult in usersFound)
{
lstUsers.Items.Add(searchResult.Properties["sAMAccountName"][0].ToString());
}
}
catch
{
}
return true;
}
I am writting an application that requires to list all users in our domain,
the code is below. My application is written in C# 2.0. I enumerate all
users fine with my code, except that when I exit the application normally I
get a popup from MS-DEV saying "There is no source code available for the
current location."
After I click ok I get "InvalidComObjectException was unhandled", "COM
object that has been separated from its underlying RCW can not be used".
Here is my code. I have a similar behavior when I try to enumerate the
domains on our network.
Can someone help me on this one? I have no idea where to look.
Thank you!
Martin
private bool GetDomainUsers()
{
try
{
// Start from the root of the active active directory
DirectoryEntry domainRoot = new DirectoryEntry(LDAP://MyDomain);
DirectorySearcher domainSearch = new DirectorySearcher(domainRoot);
// Set the search filter.
domainSearch.Filter =
("(&(objectCategory=person)(objectClass=user))");
domainSearch.PageSize = 100;
// Perform the search
SearchResultCollection usersFound = domainSearch.FindAll();
// Enumerate over each returned domain.
foreach (SearchResult searchResult in usersFound)
{
lstUsers.Items.Add(searchResult.Properties["sAMAccountName"][0].ToString());
}
}
catch
{
}
return true;
}