Page 1 of 1 1
Topic Options
#39156 - 2003-04-12 02:51 PM Changing CN withing AD
Richie19Rich77 Offline
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
#39157 - 2003-04-12 04:07 PM Re: Changing CN withing AD
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
code:
$ADSUser.Put('cn', $DisplayName)
$ADSUser.SetInfo

doesn't work? I also couldn't find any examples using the PU CN combination, either.

BTW, Richard, these type of questions should rather be posted in the COM Forum, or maybe the Scripts Forum, as these are definitely not 'Starters' questions.
_________________________
There are two types of vessels, submarines and targets.

Top
#39158 - 2003-04-12 05:14 PM Re: Changing CN withing AD
Howard Bullock Offline
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 ]
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#39159 - 2003-04-12 09:10 PM Re: Changing CN withing AD
Richie19Rich77 Offline
Seasoned Scripter
*****

Registered: 2002-08-16
Posts: 624
Loc: London, England
Ok thanks guys.

Glad it just not me that has these types of problems.

Thanks I will keep on looking, and let you know if I find it out.

RF

Top
#39160 - 2003-04-14 10:59 AM Re: Changing CN withing AD
Richie19Rich77 Offline
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 Offline
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 Offline
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 ]
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#39163 - 2003-04-15 07:28 PM Re: Changing CN withing AD
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Use fnCOMErr() - Converts COM error codes into Win32 API error codes
_________________________
There are two types of vessels, submarines and targets.

Top
#39164 - 2003-04-15 07:34 PM Re: Changing CN withing AD
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Broken Arrow,
You should not be hijaaking Richard's thread but rather starting your own.

See Topic: ABC's of KiXtart board etiquette and message to new forum users and in particular, section I.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#39165 - 2003-12-16 08:17 PM Re: Changing CN withing AD
Richie19Rich77 Offline
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
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 1471 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.069 seconds in which 0.032 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org