Hello..
I am having a little trouble with removing a computer object from a group with the following code...
The code falls over on the Member.Remove line.. even though the machine is a member of the group... with the following msg:
Cannot remove the specified item because it was not found in the specified Collection
Can anyone see where I am going wrong? Thanks in adv.
I am having a little trouble with removing a computer object from a group with the following code...
Code:
For Each oItm In lCurApps.CheckedItems
sGrp = oItm.text.ToString
Try
Dim dEntry As New DirectoryEntry(ADPROV & "CN=" & sGrp & "," & SFTOU)
Dim Members As PropertyValueCollection
Members = dEntry.Properties("member")
Members.Remove("CN=" & sHost & "," & WKSOU)
dEntry.CommitChanges()
Catch ex As Exception
MsgBox(ex.Message)
Exit Sub
End Try
The code falls over on the Member.Remove line.. even though the machine is a member of the group... with the following msg:
Cannot remove the specified item because it was not found in the specified Collection
Can anyone see where I am going wrong? Thanks in adv.