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