Solved

Display name change in Active Directory

Posted on 2009-07-13
7
410 Views
Last Modified: 2012-05-07
Trying to find a script that will automate this for me. We have an organization name change and instead of doing it manually and so time consuming. I want to see if it anyone has a script or can point me in the right direction to go through my OU and change the name from previous name to a new one.  I.E.  Ex: display name  Intercorp ITL to 24 ITC ITL  
0
Comment
Question by:cgooden01
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
7 Comments
 
LVL 57

Expert Comment

by:Mike Kline
ID: 24837783
Lots of ways to do this
admodify is a tool I'd suggest
http://www.codeplex.com/admodify
One thing i like is that it is easy to undo the changes you made if you need to.
Thanks
Mike
0
 

Author Comment

by:cgooden01
ID: 24838428
Okay..let me look more into admodify tool.   THanks..ill follow back up with you as soon as i get the result im looking to make happen..Thanks mike..
0
 

Author Comment

by:cgooden01
ID: 24838535
Will this change just the display name to a new name. thats all i need.  downloading it now
0
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 

Author Comment

by:cgooden01
ID: 24838680
Doesnt seem to be doing what i want ..I need it to show me the current display name settings, and then i just go in and make the update on all previous organization changes.  But this you have to do manually. I actually need to have the flexibility to run a query display names that have the previous organ name and then make changes to reflect new changes in display name
0
 
LVL 27

Expert Comment

by:bluntTony
ID: 24839253
Are you talking the display name for users as seen in Outlook, and by mail recipients - e.g."DISPLAY NAME" (someaddress@domain.com)?

If you want to make this attribute different to the user's actual name, you also need to modify a custom attribute on the user object to stop this display name being overwritten again after you have made the change:

extensionAttribute2 = DoNotUpdateDisplayName

What would be the rule for the users you want to change, i.e. what is the common feature they all share? If there is no common feature then it can't really be automated.

Tony

0
 
LVL 27

Expert Comment

by:bluntTony
ID: 24839424
Sorry - re-read your question. So you want to change all users with a displayName which includes 'Intercorp' and replace this with '24 ITC'.

The below script would do it.

Run it via cscript with these switches to output the users which will be changed:

cscript change_display_names.vbs /find:"Intercorp" /replace:"24 ITC"

If you're happy with these changes, run it with the following switch:

cscript change_display_names.vbs /find:"Intercorp" /replace:"24 ITC" /forreal:YES

This will change the displayName attribute, and update extension Attribute2 to enable this displayName to stick. Like I said, this is necessary only if the displayName is different to the user's name.

Hope this helps...
strForReal = WScript.Arguments.Named("ForReal")
strOldString = WScript.Arguments.Named("Find")
strNewString = WScript.Arguments.Named("Replace")
 
Set objRoot = GetObject("LDAP://RootDSE")
strBase = "<LDAP://" & objRoot.get("defaultNamingContext") & ">;"
strFilter = "(&(objectclass=user)(displayName=*" & strOldString & "*));" 
strAttrs  = "distinguishedName;"
strScope  = "subtree"
 
Set objConn = CreateObject("ADODB.Connection")
Set objComm =   CreateObject("ADODB.Command")
objConn.Provider = "ADsDSOObject"
objConn.Open "Active Directory Provider"
Set objComm.ActiveConnection = objConn
objComm.Properties("Page Size") = 1000
objComm.CommandText = strBase & strFilter & strAttrs & strScope
Set objRS = objComm.Execute
 
If objRs.RecordCount > 0 Then
	objRS.MoveFirst
	Do
		Set objUser = GetObject("LDAP://" & Replace(objRS.Fields(0).Value,"/","\/"))
		strNewDisplayName = Replace(objUser.displayName,strOldString,strNewString)
		
		WScript.Echo objUser.cn & String(40-Len(objUser.cn)," ") & " : (" & objUser.displayName & " to " _
		 	& "be changed to " & strNewDisplayName & ")"
		If UCase(strForReal) = "YES" Then
			objUser.displayName = strNewDisplayName
			objUser.extensionAttribute2 = "DoNotUpdateDisplayName"
			objUser.SetInfo
		End If 	
		
		objRS.MoveNext
	Loop Until objRS.EOF
End If
 
Set objRoot = Nothing
Set objComm = Nothing
Set objConn = Nothing
Set objUser = Nothing
Set objRS = Nothing

Open in new window

0
 
LVL 27

Accepted Solution

by:
bluntTony earned 500 total points
ID: 24839431
Forgot to say: this is VBScript. Save as a .vbs file in order to run it.
0

Featured Post

Free NetCrunch network monitor licenses!

Only on Experts-Exchange: Sign-up for a free-trial and we'll send you your permanent license!

Here is what you get: 30 Nodes | Unlimited Sensors | No Time Restrictions | Absolutely FREE!

Act now. This offer ends July 14, 2017.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In threads here at EE, each comment has a unique Identifier (ID). It is easy to get the full path for an ID via the right-click context menu. However, we often want to post a short link within a thread rather than the full link. This article shows a…
A quick Powershell script I wrote to find old program installations and check versions of a specific file across the network.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question