Asked By
Ava White
10 points
N/A
Posted on - 04/06/2012
How to move user in active directory console from one OU to another? I need a little help with this.
Thanks.
I need help in moving user in active directory
Â
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
Â
Or you may also try this:
VB to C++ Converter Free Edition
Â
Wish you will be get rid.
I need help in moving user in active directory
Â
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
Â