Discussion:
MoveHere...Error when move user between OU
(too old to reply)
Charles
2003-08-07 19:48:00 UTC
Permalink
Can anybody help me !!!

I wrote a Vb code to move users between OU.
For each OU I have multiple groups inside.

Example :
Before move ==> OU=867520, group=867520ADM, group=867520ENS, group=867520GPI
After move ==> OU=867560, group=867520ADM, group=867520ENS, group=867520GPI

I want only the OU to be change, the groups must stay the way they are.

When I run the code, I receive an error...There is no such object on the server
but after verification all objects are present.

This is a part of my code to test one user :

Set usr = GetObject("LDAP://cn=laura cole,ou=867520,dc=csdgs,dc=qc,dc=ca")
Set cont = GetObject("LDAP://ou=867560,dc=csdgs,dc=qc,dc=ca")
cont.MoveHere usr.ADsPath, vbNullString

Please if anybody knows help me quickly !!!

Thank you very very very much...
Robbie Allen
2003-08-07 20:28:44 UTC
Permalink
You need to pass usr.Name as the second parameter. Try this:

cont.MoveHere usr.ADsPath, usr.Name

Here is an example:
http://www.rallenhome.com/books/adcookbook/source/06/6.06-move_user.vbs.txt


Robbie Allen
http://www.rallenhome.com/
Post by Charles
Can anybody help me !!!
I wrote a Vb code to move users between OU.
For each OU I have multiple groups inside.
Before move ==> OU=867520, group=867520ADM, group=867520ENS,
group=867520GPI
Post by Charles
After move ==> OU=867560, group=867520ADM, group=867520ENS,
group=867520GPI
Post by Charles
I want only the OU to be change, the groups must stay the way they are.
When I run the code, I receive an error...There is no such object on the server
but after verification all objects are present.
Set usr = GetObject("LDAP://cn=laura cole,ou=867520,dc=csdgs,dc=qc,dc=ca")
Set cont = GetObject("LDAP://ou=867560,dc=csdgs,dc=qc,dc=ca")
cont.MoveHere usr.ADsPath, vbNullString
Please if anybody knows help me quickly !!!
Thank you very very very much...
Richard Mueller [MVP]
2003-08-08 15:44:32 UTC
Permalink
Hi,

The documentation says that to move a user with the MoveHere method of the
container object, the second argument can be either the Relative
Distinguished Name (usr.Name), or vbNullString. So, I think something else
is wrong. If your error message is raised on the first statement (Set usr),
then the object was not found and the Distinguished Name (DN) of the user is
incorrect. As a test, see if you can display the user object Relative
Distinguished Name (RDN). For example:

Set usr = GetObject("LDAP://cn=laura cole,ou=867520,dc=csdgs,dc=qc,dc=ca")
Wscript.Echo "User name: " & usr.Name

If the error is raised on the second statment, then the DN of the OU is
wrong. Again, try to output the RDN of the OU:

Set cont = GetObject("LDAP://ou=867560,dc=csdgs,dc=qc,dc=ca")
Wscript.Echo "OU name: " & cont.Name

Let us know what works.
--
Richard
Microsoft MVP Scripting and ADSI
HilltopLab web site - http://www.rlmueller.net
--
Post by Robbie Allen
cont.MoveHere usr.ADsPath, usr.Name
http://www.rallenhome.com/books/adcookbook/source/06/6.06-move_user.vbs.txt
Post by Robbie Allen
Robbie Allen
http://www.rallenhome.com/
Post by Charles
Can anybody help me !!!
I wrote a Vb code to move users between OU.
For each OU I have multiple groups inside.
Before move ==> OU=867520, group=867520ADM, group=867520ENS,
group=867520GPI
Post by Charles
After move ==> OU=867560, group=867520ADM, group=867520ENS,
group=867520GPI
Post by Charles
I want only the OU to be change, the groups must stay the way they are.
When I run the code, I receive an error...There is no such object on the
server
Post by Charles
but after verification all objects are present.
Set usr = GetObject("LDAP://cn=laura
cole,ou=867520,dc=csdgs,dc=qc,dc=ca")
Post by Robbie Allen
Post by Charles
Set cont = GetObject("LDAP://ou=867560,dc=csdgs,dc=qc,dc=ca")
cont.MoveHere usr.ADsPath, vbNullString
Please if anybody knows help me quickly !!!
Thank you very very very much...
Charles
2003-08-11 15:26:01 UTC
Permalink
Thank you Richard,
The two lines OLD OU and NEW OU run correctly and I can view the name,
but the error raise when MoveHere is executed,I receive an return code
:
0x80072035L LDAP_UNWILLING_TO_PERFORM


So, I found an article from microsoft 326978 but I think and I HOPE
that is not my case...

To help you to understand, I give you a little description of the
structure we are using in our office :


Domain ===> Dom1
|
|
|---> 867520
|----> 867520ADM
|----> 867520ENS
|----> 867520GPI
|
|---> 867521
|----> 867521ADM
|----> 867521ENS
|----> 867521GPI
|
|---> 867522
|----> ...
|----> ...
|----> ...
|
|---> ...


The Users are defines at the root of each OU and each user is member
of one or more group(s) of this OU.
Normally, the user will stay in the current OU assigned, but some time
it is possible the staff has a temporary department swap and we must
change the OU but not the group(s).

thank you
Post by Richard Mueller [MVP]
Hi,
The documentation says that to move a user with the MoveHere method of the
container object, the second argument can be either the Relative
Distinguished Name (usr.Name), or vbNullString. So, I think something else
is wrong. If your error message is raised on the first statement (Set usr),
then the object was not found and the Distinguished Name (DN) of the user is
incorrect. As a test, see if you can display the user object Relative
Set usr = GetObject("LDAP://cn=laura cole,ou=867520,dc=csdgs,dc=qc,dc=ca")
Wscript.Echo "User name: " & usr.Name
If the error is raised on the second statment, then the DN of the OU is
Set cont = GetObject("LDAP://ou=867560,dc=csdgs,dc=qc,dc=ca")
Wscript.Echo "OU name: " & cont.Name
Let us know what works.
--
Richard
Microsoft MVP Scripting and ADSI
HilltopLab web site - http://www.rlmueller.net
--
Post by Robbie Allen
cont.MoveHere usr.ADsPath, usr.Name
http://www.rallenhome.com/books/adcookbook/source/06/6.06-move_user.vbs.txt
Post by Robbie Allen
Robbie Allen
http://www.rallenhome.com/
Post by Charles
Can anybody help me !!!
I wrote a Vb code to move users between OU.
For each OU I have multiple groups inside.
Before move ==> OU=867520, group=867520ADM, group=867520ENS,
group=867520GPI
Post by Robbie Allen
Post by Charles
After move ==> OU=867560, group=867520ADM, group=867520ENS,
group=867520GPI
Post by Robbie Allen
Post by Charles
I want only the OU to be change, the groups must stay the way they
are.
Post by Robbie Allen
Post by Charles
When I run the code, I receive an error...There is no such object on the
server
Post by Robbie Allen
Post by Charles
but after verification all objects are present.
Set usr = GetObject("LDAP://cn=laura
cole,ou=867520,dc=csdgs,dc=qc,dc=ca")
Post by Robbie Allen
Post by Charles
Set cont = GetObject("LDAP://ou=867560,dc=csdgs,dc=qc,dc=ca")
cont.MoveHere usr.ADsPath, vbNullString
Please if anybody knows help me quickly !!!
Thank you very very very much...
Loading...