MaDMaRTiGaN
Newcomer
- Joined
- Jan 5, 2006
- Messages
- 1
Hi,
I'm trying to create a web page which allows me to list the members of the local Administrators group of a client system. I found some code parts which can list the members (using WMI) but these cannot add or remove members from the group. I switched to using a DirectoryEntry object but when I run the code below, only one account is returned although the administrators group contains more (both local and domain) accounts. (note that txtOutput is a textbox on my webpage). Can someone help me out?
I'm trying to create a web page which allows me to list the members of the local Administrators group of a client system. I found some code parts which can list the members (using WMI) but these cannot add or remove members from the group. I switched to using a DirectoryEntry object but when I run the code below, only one account is returned although the administrators group contains more (both local and domain) accounts. (note that txtOutput is a textbox on my webpage). Can someone help me out?
Code:
Dim strComputer As String = "computer"
Dim strAccount As String = "administrator"
Dim strPassword As String = "secret"
Dim locPath As String = "WinNT://" & strComputer & "/Administrators,group"
Dim localGroup As DirectoryEntry
localGroup = New DirectoryEntry(locPath, strComputer & "\" & strAccount, strPassword)
Dim allMembers As Object = localGroup.Invoke("Members")
Dim groupMember As Object
For Each groupMember In CType(allMembers, IEnumerable)
Dim member As New DirectoryEntry(groupMember)
txtOutput.Text = txtOutput.Text & member.Path & vbCrLf
Next