No of visitors who read this post: 159
Type: Question
Author: Ava White
No votes yet

How to move user in active directory console from one OU to another? I need a little help with this.

Thanks.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

#

You have to follow the process below I given. It’s a easy process if everything goes well with your activities to do it.
 
At first you have to add user into other OU by following this and done-
 
PublicSubAddToGroup(ByValuserDn AsString,ByValgroupDn AsString)
 
Try
 
DimdirEntry AsDirectoryEntry=NewDirectoryEntry(("LDAP://"+groupDn))
 
dirEntry.Properties("member").Add(userDn)
 
dirEntry.CommitChanges
 
dirEntry.Close
 
CatchE AsSystem.DirectoryServices.DirectoryServicesCOMException
 
doSomething with E.Message.ToString();
 
End Try
 
End Sub
 
 
Now you must have to remove from previous OU by doing this-
 
PublicSubRemoveUserFromGroup(ByValuserDn AsString,ByValgroupDn AsString)
 
Try
 
DimdirEntry AsDirectoryEntry=NewDirectoryEntry(("LDAP://"+groupDn))
 
dirEntry.Properties("member").Remove(userDn)
 
dirEntry.CommitChanges
 
dirEntry.Close
 
CatchE AsSystem.DirectoryServices.DirectoryServicesCOMException
 
doSomething with E.Message.ToString();
 
End Try
 
End Sub
 
Also you can use code translator for fill up your purposes. This may be work more efficiently for you-
 
 
Wish you will be get rid.

# (Solution Accepted)

Hello Ava,
Use the code given below to move a user in the active directory console from one OU to a separate OU.
 
1) You have to add the user to the other OU first. Follow this code section
Public Sub AddToGroup(ByVal userDn As String, ByVal groupDn As String)
        Try
            Dim dirEntry As DirectoryEntry = New DirectoryEntry(("LDAP://" + groupDn))
            dirEntry.Properties("member").Add(userDn)
            dirEntry.CommitChanges
            dirEntry.Close
        Catch E As System.DirectoryServices.DirectoryServicesCOMException
            'doSomething with E.Message.ToString();
        End Try
    End Sub
2) Then you have to remove the user from previous OU.
 
 
Public Sub RemoveUserFromGroup(ByVal userDn As String, ByVal groupDn As String)
        Try 
            Dim dirEntry As DirectoryEntry = New DirectoryEntry(("LDAP://" + groupDn))
            dirEntry.Properties("member").Remove(userDn)
            dirEntry.CommitChanges
            dirEntry.Close
        Catch E As System.DirectoryServices.DirectoryServicesCOMException
            'doSomething with E.Message.ToString();
        End Try
    End Sub

Follow this for more info: [http://forums.asp.net/t/1614982.aspx]