Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Group MEmebership with AD & Directory Searcher

Status
Not open for further replies.

tEkHEd

IS-IT--Management
Jan 29, 2003
261
GB
Hello..

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.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top