View Single Post
  #3 (permalink)  
Old 10-24-2008, 5:53 AM
sebasjuh sebasjuh is offline
VB.NET Forum Newbie
.NET Framework: .NET 2.0 (VS 2005)
 
Join Date: Dec 2007
Posts: 13
Reputation: 30
sebasjuh is on a distinguished programming path ahead
Default

Thank you MattP for your reply.
I already found that website but when I use that code for deleting a user from a group I got this error:

Quote:
Name 'GetDirectoryObject' is not declared.
I don't know how to fix this....


Edit: This is the code btw:
Code:
Public Shared Sub RemoveUserFromGroup(ByVal UserName As String, _
                  ByVal GroupName As String)

    Dim Domain As New String("")
    
    'get reference to group
    Domain = "/CN=" + GroupName + ",CN=Users," + GetLDAPDomain()
    Dim oGroup As DirectoryEntry = GetDirectoryObject(Domain)
    
    'get reference to user
    Domain = "/CN=" + UserName + ",CN=Users," + GetLDAPDomain()
    Dim oUser As DirectoryEntry = GetDirectoryObject(Domain)
    
    'Add the user to the group via the invoke method
    oGroup.Invoke("Remove", New Object() {oUser.Path.ToString()})
    
    oGroup.Close()
    oUser.Close()
End Sub

Last edited by sebasjuh; 10-24-2008 at 6:43 AM.
Reply With Quote