move user based on Attribute - help

Anything VBScript-related, including Windows Script Host, WMI, ADSI, and more.
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 13 years and 10 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
matrix101
Posts: 7
Last visit: Mon Jun 21, 2010 12:01 pm

move user based on Attribute - help

Post by matrix101 »

hi all,

I have found this script and it works - moving users from one OU to another OU.

Question = how can I modify it to only move users who have attribute "company=2" only. Thank you apprepricate the help as I'm new to scripting.

**************Set objNewOU = GetObject("LDAP://ou=qdobaemp,ou=users,ou=managed objects,dc=testcorp,dc=testjack,dc=net")Set objOldOU = GetObject("LDAP://ou=clan,ou=users,ou=managed objects,dc=testcorp,dc=test,dc=net")
objOldOU.Filter = Array("user")
For Each objUser in objOldOU objNewOU.MoveHere objUser.ADsPath, vbNullString Next
end if
User avatar
matrix101
Posts: 7
Last visit: Mon Jun 21, 2010 12:01 pm

move user based on Attribute - help

Post by matrix101 »

hi all,

I have found this script and it works - moving users from one OU to another OU.

Question = how can I modify it to only move users who have attribute "company=2" only. Thank you apprepricate the help as I'm new to scripting.

**************Set objNewOU = GetObject("LDAP://ou=qdobaemp,ou=users,ou=managed objects,dc=testcorp,dc=testjack,dc=net")Set objOldOU = GetObject("LDAP://ou=clan,ou=users,ou=managed objects,dc=testcorp,dc=test,dc=net")
objOldOU.Filter = Array("user")
For Each objUser in objOldOU objNewOU.MoveHere objUser.ADsPath, vbNullString Next
end if
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

move user based on Attribute - help

Post by jvierra »

If objUser.Company = 2 Then
' move
End If
This topic is 13 years and 10 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked