Wiseman82 Posted February 27, 2008 Posted February 27, 2008 Script to update user attributes from a CSV File: http://www.wisesoft.co.uk/Scripts/display_script.aspx?id=178 I posted this script in response to a different thread: http://www.edugeek.net/forums/showthread.php?t=15674 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. 1
Wiseman82 Posted February 28, 2008 Author Posted February 28, 2008 Does it deal with CN changes now? Yes. I added the following code to handle the cn attribute: SELECT CASE strAttribute CASE "cn" 'Special handling required for common-name attribute [b]DIM objContainer set objContainer = GetObject(objUser.Parent) objContainer.MoveHere objUser.ADsPath,"cn=" & newval[/b] CASE ELSE ' Any other attribute ' Update attribute objUser.put strAttribute,newVal END SELECT You need to use the "MoveHere" method of the container object (OU) to rename a user account. 1
Geoff Posted February 28, 2008 Posted February 28, 2008 I broke it. 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.
Wiseman82 Posted February 28, 2008 Author Posted February 28, 2008 I broke it. 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. It looks like an account with the same common-name already exists within the same container (OU). The common-name is used as part of an objects distinguished name and must be unique within its container. 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.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now