PantoffelSlippers
asked on
Get all AD groups in one OU
Hi experts,
I'm trying to query Active directory using VB.Net on .Net Framework 3.5
I need to get all security groups in a specific OU.
I've got:
Dim searcher As New DirectorySearcher()
searcher.Filter = "(&(Objectcategory=group)( OU=ThisIsT heOUThatIW ant,OU=Gro ups,OU=Sec ondLevel,O U=CompanyL evel))"
It's not working. I get 0 results. I tried variations but none works.
I have not written code at all in the last 5 years - only started again now in the last week.
Please help me to get this working.
Thanks
I'm trying to query Active directory using VB.Net on .Net Framework 3.5
I need to get all security groups in a specific OU.
I've got:
Dim searcher As New DirectorySearcher()
searcher.Filter = "(&(Objectcategory=group)(
It's not working. I get 0 results. I tried variations but none works.
I have not written code at all in the last 5 years - only started again now in the last week.
Please help me to get this working.
Thanks
ASKER
Thanks Will,
In my other post it worked.
In this case though, it forms part of a larger system/application so I need to incorporate it into a .Net application.
In my other post it worked.
In this case though, it forms part of a larger system/application so I need to incorporate it into a .Net application.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks Robert - let me try that
ASKER
Robert,
I'm getting the following error:
A first chance exception of type 'System.DirectoryServices. DirectoryS ervicesCOM Exception' occurred in System.DirectoryServices.d ll
on
Dim objSearchResultCollection As SearchResultCollection = searcher.FindAll
I'm trying to troubleshoot now....
I'm getting the following error:
A first chance exception of type 'System.DirectoryServices.
on
Dim objSearchResultCollection As SearchResultCollection = searcher.FindAll
I'm trying to troubleshoot now....
ASKER
Robert,
Got it running - let me wrap my head around results.
Thanks
Got it running - let me wrap my head around results.
Thanks
The whole block of looping through the results I constructed once because I was gettting some strange results, something to do with multi-valued fields and possibly typing although I've always only used strings. But something like Properties("name") just doesn't fly...
ASKER
It's what I wanted - and it works - thanks
Open in new window
The command above will return all security/distribution groups in the "testou". For yours change the OU and also DC=yourdomain,DC=com.
Will.