Geoff (28th February 2008)
Script to update user attributes from a CSV File:
I posted this script in response to a different thread:
It also seemed appropriate to post it here in it's own thread. (People are more likely to look for this type of thing here)
I hope you find the script useful.
Does it deal with CN changes now?
You need to use the "MoveHere" method of the container object (OU) to rename a user account.Code:SELECT CASE strAttribute CASE "cn" 'Special handling required for common-name attribute DIM objContainer set objContainer = GetObject(objUser.Parent) objContainer.MoveHere objUser.ADsPath,"cn=" & newval CASE ELSE ' Any other attribute ' Update attribute objUser.put strAttribute,newVal END SELECT
Lovely, I shall give it a go later.
I broke it.
Code:C:\Documents and Settings\Administrator\Desktop\Geoffs Scripts>cscript usermod.vbs Microsoft (R) Windows Script Host Version 5.6 Copyright (C) Microsoft Corporation 1996-2001. All rights reserved. LDAP://CN=JBirch07,OU=Year9,OU=Pupils,OU=All Users,DC=carrhill,DC=lancs,DC=sch,DC=uk Change sn from 'birch' to 'Birch' Change givenName from 'jodie' to 'Jodie' Change displayName from 'JBirch07' to 'Jodie Birch' Change name from 'JBirch07' to 'Jodie Birch' Change cn from 'JBirch07' to 'Jodie Birch' C:\Documents and Settings\Administrator\Desktop\Geoffs Scripts\usermod.vbs(124,8) (null): The server is unwilling to process the request.
I've modified the code to allow the script to report an error and continue processing the rest of the updates.
I've also added some more detailed instructions on how to use the script.
I'll retest tomorrow and check.
There are currently 1 users browsing this thread. (0 members and 1 guests)