Get domains & workgroups-reply plzzzz
-
How can i get the domain names & workgroups separately in a network usin vb.net?Plzz replyyyy
-
How can i get the domain names & workgroups separately in a network usin vb.net?Plzz replyyyy
Look up the System.DirectoryServices namespace on MSDN, and check for examples here on CP for the same thing. What a piece of work is man, how noble in reason, how infinite in faculties, in form and moving how express and admirable . . . and yet to me, what is this quintessence of dust? -- Hamlet, Act II, Scene ii.
-
Look up the System.DirectoryServices namespace on MSDN, and check for examples here on CP for the same thing. What a piece of work is man, how noble in reason, how infinite in faculties, in form and moving how express and admirable . . . and yet to me, what is this quintessence of dust? -- Hamlet, Act II, Scene ii.
-
I used the same class n namespace n passed WinNT: as the query but it lists all the domains n workgroups together.I need those separately.Also I want to get the machines in the workgroup.Whats the query that I should pass.Plzzz replllyyyyy
I think the key is to enumerate the Properties collection of each child node in the collection of DirectoryEntry children. While there may be a more elegant way of doing so, the way that I was able to get a list of users, for example, was to do something like this:
Dim entry As New DirectoryServices.DirectoryEntry For Each child As DirectoryServices.DirectoryEntry In entry.Children Dim propertyValue As Integer = 0 Try propertyValue = CType(child.Properties("UserFlags").Value, Integer) Catch ex As Exception ' if it throws an exception, it's not a user item propertyValue = 0 End Try If (propertyValue = 513) Then Console.WriteLine(child.Name) End If Next
If you look at the property names in the Properties collection, you should be able to isolate which ones are Domains, which ones are workgroups and which ones are users, etc. I believe there may be a more elegant solution, but I haven't found the best reference for that solution yet. What a piece of work is man, how noble in reason, how infinite in faculties, in form and moving how express and admirable . . . and yet to me, what is this quintessence of dust? -- Hamlet, Act II, Scene ii.