Jump to content

Update Active Directory User Attributes from a CSV File


Recommended Posts

Posted
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.

  • Thanks 1
Posted

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.

Posted
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. :)

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 account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...