+ Post New Thread
Results 1 to 7 of 7
Scripts Thread, Update Active Directory User Attributes from a CSV File in Coding and Web Development; Script to update user attributes from a CSV File: http://www.wisesoft.co.uk/Scripts/di...pt.aspx?id=178 I posted this script in response to a different thread: ...
  1. #1
    Wiseman82's Avatar
    Join Date
    Jan 2006
    Location
    North East
    Posts
    48
    Thank Post
    3
    Thanked 14 Times in 11 Posts
    Rep Power
    21

    Update Active Directory User Attributes from a CSV File

    Script to update user attributes from a CSV File:

    http://www.wisesoft.co.uk/Scripts/di...pt.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.

  2. Thanks to Wiseman82 from:

    Geoff (28th February 2008)

  3. #2

    Geoff's Avatar
    Join Date
    Jun 2005
    Location
    Fylde, Lancs, UK.
    Posts
    11,813
    Thank Post
    110
    Thanked 586 Times in 507 Posts
    Blog Entries
    1
    Rep Power
    225
    Does it deal with CN changes now?

  4. #3
    Wiseman82's Avatar
    Join Date
    Jan 2006
    Location
    North East
    Posts
    48
    Thank Post
    3
    Thanked 14 Times in 11 Posts
    Rep Power
    21
    Quote Originally Posted by Geoff View Post
    Does it deal with CN changes now?
    Yes. I added the following code to handle the cn attribute:

    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
    You need to use the "MoveHere" method of the container object (OU) to rename a user account.

  5. Thanks to Wiseman82 from:

    Geoff (28th February 2008)

  6. #4

    Geoff's Avatar
    Join Date
    Jun 2005
    Location
    Fylde, Lancs, UK.
    Posts
    11,813
    Thank Post
    110
    Thanked 586 Times in 507 Posts
    Blog Entries
    1
    Rep Power
    225
    Lovely, I shall give it a go later.

  7. #5

    Geoff's Avatar
    Join Date
    Jun 2005
    Location
    Fylde, Lancs, UK.
    Posts
    11,813
    Thank Post
    110
    Thanked 586 Times in 507 Posts
    Blog Entries
    1
    Rep Power
    225
    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.

  8. #6
    Wiseman82's Avatar
    Join Date
    Jan 2006
    Location
    North East
    Posts
    48
    Thank Post
    3
    Thanked 14 Times in 11 Posts
    Rep Power
    21
    Quote Originally Posted by Geoff View Post
    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.
    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.

  9. #7

    Geoff's Avatar
    Join Date
    Jun 2005
    Location
    Fylde, Lancs, UK.
    Posts
    11,813
    Thank Post
    110
    Thanked 586 Times in 507 Posts
    Blog Entries
    1
    Rep Power
    225
    I'll retest tomorrow and check.

SHARE:
+ Post New Thread

Similar Threads

  1. Bulk update of Active Directory user info
    By Geoff in forum Windows
    Replies: 30
    Last Post: 14th June 2013, 04:04 PM
  2. Active Directory - Single and Bulk User creation and FREE!!
    By siuko in forum How do you do....it?
    Replies: 39
    Last Post: 20th June 2012, 11:29 AM
  3. Update Active Directory with mySQL table data?
    By netadmin in forum Windows
    Replies: 8
    Last Post: 30th October 2007, 10:43 PM
  4. Replies: 3
    Last Post: 16th November 2006, 09:55 PM
  5. Replies: 4
    Last Post: 10th November 2006, 11:28 AM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •