#39156 - 2003-04-12 02:51 PM
Changing CN withing AD
|
Richie19Rich77
Seasoned Scripter
   
Registered: 2002-08-16
Posts: 624
Loc: London, England
|
Hi
Me again !!.
I can change all properties on AD apart from the CN name, this is the name displayed withing the AD Tree.
This is the code I am doing which works for everything else.
code:
$ADSUser.Put ("cn", $DisplayName)
The $displayname works fine for the Display Name, and I want the CN to be the same.
I have tried this using LDAP and WinNT connectors, have looked through the ADSI help file which I have been using for all the other properties and nothing.
Any clues ???.
Thanks
|
|
Top
|
|
|
|
#39158 - 2003-04-12 05:14 PM
Re: Changing CN withing AD
|
Howard Bullock
KiX Supporter
   
Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
|
You could try the MOVEHERE method to move it to the same container while renaming it. Not sure if it works or not...just a thought. [ 12. April 2003, 17:14: Message edited by: Howard Bullock ]
|
|
Top
|
|
|
|
#39160 - 2003-04-14 10:59 AM
Re: Changing CN withing AD
|
Richie19Rich77
Seasoned Scripter
   
Registered: 2002-08-16
Posts: 624
Loc: London, England
|
Yep MoveHere does work, below is the code if anyone needs it.
Thanks
code:
$adsuser = GetObject("LDAP://OU=Admin Users,OU=QEH Users,DC=qeh-tr,DC=sthames,DC=nhs,DC=uk") $ADSUser.MoveHere("LDAP://CN=Richard Farthing,OU=Admin Users,OU=QEH Users,DC=qeh-tr,DC=sthames,DC=nhs,DC=uk", "CN=Mr Farthing")
Rich
|
|
Top
|
|
|
|
#39161 - 2003-04-15 06:28 PM
Re: Changing CN withing AD
|
Broken Arrow
Fresh Scripter
Registered: 2002-09-24
Posts: 8
Loc: US
|
Tried using this code but getting this error -2147352567:COM exception error "MoveHere" ((null) - (null)) [-2147352567/80020009] Any ideas?
|
|
Top
|
|
|
|
#39162 - 2003-04-15 07:24 PM
Re: Changing CN withing AD
|
Howard Bullock
KiX Supporter
   
Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
|
Without seeing the code you are using, it is hard to know what is happening. [ 15. April 2003, 19:25: Message edited by: Howard Bullock ]
|
|
Top
|
|
|
|
#39165 - 2003-12-16 08:17 PM
Re: Changing CN withing AD
|
Richie19Rich77
Seasoned Scripter
   
Registered: 2002-08-16
Posts: 624
Loc: London, England
|
Just gone back to this old post, and My code is wrong.
I have just worked out why this goes wrong, for some reason you have to hide the return of the .MoveHere command otherwise you will get an error.
It will work but your script will drop out, just put $= before it.
I think this has been spoken about before with KiX and com objects.
It took me ages to work out what was happening .
Hope this will help someone in the future.
Code:
$ADSUser = GetObject("LDAP://OU=Users,DC=qeh-tr,DC=sthames,DC=nhs,DC=uk") $=$ADSUser.MoveHere("LDAP://CN=HelpMe,OU=Users,DC=qeh-tr,DC=sthames,DC=nhs,DC=uk","CN=Testing")
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
1 registered
(Allen)
and 1607 anonymous users online.
|
|
|