Aaarrrgghhh.... This is so frusterating... I found some code that enumerates a local group without activeds and it works great, problem is that it doesnt run when put into the onshutdown() method of a service. I get the following error when trying to invoke the members of the group.
This operation is only allowed on the primary domain controller of the domain
It works fine in the onstop() method when I stop the service manually. I have the service running under the system account and I have it depending everything I can think of (Workstation, Server, Computer Browser, and Net Logon). Here is the code that is running. Any help would be appreciated...
Thanks,
Landon.
Try
f = IO.File.CreateText("c:\test.txt")
f.WriteLine("Connecting")
Dim localGroup As New DirectoryEntry("WinNT://machinename/test,group")
f.WriteLine("Getting members")
Dim allMembers As Object = localGroup.Invoke("Members")
Dim groupMember As Object
f.WriteLine("Enum")
For Each groupMember In CType(allMembers, IEnumerable)
Dim member As New DirectoryEntry(groupMember)
f.WriteLine("Removing")
localGroup.Invoke("Remove", member.Path)
Next
Catch
f.WriteLine(Err.Description)
End Try
f.Flush()
f.Close()