hai, to get list of all users in the domain i tried following code in asp.net code behind file but it throws an error stating "specified cast is not valid" code i have written in page_load is as follows: Dim oParent As IADs Dim oContainer As IADsContainer oParent
= GetObject("WinNT://In-devserver01") oContainer = oParent Response.Write("Domain Name:" & oParent.Name) Dim oUser As IADsUser Dim ogroup As IADsGroup For Each oUser In oContainer ' error is shown here Response.Write("User Name:" & oUser.Name) Response.Write("
") Response.Write("Description:" & oUser.Description) Next oUser = Nothing oParent = Nothing oContainer = Nothing and i have created reference for ActiveDs and imported system.security.principal, activeds, system.directoryservices what am i supposed to do now,
kindly help me out thanks
Not everything in that collection (IADsGroup) is of the type IADsUser... In fact, you should use a more general type in your foreach loop and check the type of each returned element of the collection whether it's a user or not. If it's not a user, go on to
the next item in the collection. Can this help you???
sivasankari
Member
80 Points
16 Posts
specified cast is not valid
Aug 05, 2003 12:10 PM|LINK
") Response.Write("Description:" & oUser.Description) Next oUser = Nothing oParent = Nothing oContainer = Nothing and i have created reference for ActiveDs and imported system.security.principal, activeds, system.directoryservices what am i supposed to do now, kindly help me out thanks
bdesmet
Star
8255 Points
1651 Posts
Re: specified cast is not valid
Aug 09, 2003 11:54 PM|LINK
Visit www.msdn.be, www.bartdesmet.net