Directory Programming .NET

Active Directory and ADAM programming support for .NET developers
Welcome to Directory Programming .NET Sign in | Join | Help
in Search

Can not remove a user from a group. Please help.

Last post 08-15-2008, 12:12 PM by dunnry. 2 replies.
Sort Posts: Previous Next
  •  08-13-2008, 6:30 PM 4423

    Can not remove a user from a group. Please help.

    I'm having an issue removing a person from a group.  I receive the following error:

    The server is unwilling to process the request. (Exception from HRESULT: 0x80072035)

    Here's my code (Sorry it's in VB.NET :-) )

    The sGroupDN is the DN of the group I'm trying to remove the person from.
    We are at Windows 2003 Functional level in the forest and domain.
    I get the error on the CommitChanges method.

        Private Sub removeGroup(ByVal sGroupDN As String, ByVal sUID As String)
            Dim entry As New DirectoryEntry("LDAP://MRP03:389/" & sGroupDN, cLdapUID, cLdapPWD, AuthenticationTypes.Secure)
            Using entry
                Try
                    entry.Properties("member").Remove("CN=Bob Smith")
                    entry.CommitChanges()
                Catch ex As Exception
                    writeLog("ERROR - REMOVE GROUPS: " & sUID & " | " & ex.Message.ToString)
                End Try
            End Using
        End Sub

  •  08-14-2008, 8:45 AM 4424 in reply to 4423

    Re: Can not remove a user from a group. Please help.

    I Feel stupid.  The remove method uses a DN not CN.

    AARGH.... too many late nights.

  •  08-15-2008, 12:12 PM 4437 in reply to 4424

    Re: Can not remove a user from a group. Please help.

    There are some samples for this actually that you can download here (if you haven't seen them yet).  While you might have to apologize to me for VB.NET (not really :)), Joe is a native VB'er, so he feels right at home with it.  It's only me that has to struggle to remember my VB.NET syntax.

    Ryan Dunn
    Extemporaneous Mumblings
    The .NET Developer's Guide to Directory Services Programming
View as RSS news feed in XML