Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How-to reformat all the phone numbers in Active Directory?

Posted on 2007-04-10
6
Medium Priority
?
500 Views
Last Modified: 2012-03-22
I need a solution to search and replace information in the phone fields in Active Directory.

The current format of the number cause problem when it is synchronized with PDAs/Smartphone.

I need to reformat all the phone numbers to remove "(0)".

Is there an easy solution?

Thanks.
0
Comment
Question by:Yann de Champlain
[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
6 Comments
 
LVL 30

Expert Comment

by:LauraEHunterMVP
ID: 18884708
If I'm understanding you correctly, you have phone numbers listed in your users' properties sheets as:

(0)215-555-1212

And you need it to be formatted as

215-555-1212

?

How many users are we talking about?

If each phone number is formatted -the same way-, this is basic string manipulation that can be done relatively easily using a script.

If the phone number formatting is all over the map, IE, some are (0) 215-555-1212, some are 0-215-555-1212, some are (215) 5551212, it's going to be much easier to just create an Excel spreadsheet containing each user and their phone number and just manually reload them.  

Either way, moving forward you'll need to either enforce this procedurally with whomever creates your user accounts, or else invest in some sort of account provisioning software that can enforce the formatting rules that you need.
0
 

Author Comment

by:Yann de Champlain
ID: 18887598
I am Business Project Manager.  The people in charge of the AD are trying To Bul...t me saying that it is not possible. I know they're wrong. So I need to bring the solution to make them move.

We are talking of about 2500 user I would say. maybe more.   As far as I know, we only need to remove "(0)" all the numbers seems to be in a clean format.  So, I would not really need to user RegEx formlua.  But the problem is the tool, util to perform this modification. This is a company with a lot of security rules and standards.

This is Europeen number so it look like "+33 (0)1 11 22 33 44"
0
 
LVL 30

Expert Comment

by:LauraEHunterMVP
ID: 18888524
The following VBScript will take a single user account and modify its telephone number properties - I don't have a script handy that'll do precisely what you're looking for (query AD for all user objects and clean up the phone number), but let me know if you need it and I can put it together.

Const ADS_PROPERTY_UPDATE = 2
Set objUser = GetObject _
    ("LDAP://cn=MyerKen,ou=Management,dc=NA,dc=fabrikam,dc=com")
 
objUser.Put "homePhone", "(425) 555-0100"
objUser.Put "pager", "(425) 555-0101"
objUser.Put "mobile", "(425) 555-0102"
objUser.Put "facsimileTelephoneNumber", "(425) 555-0103"  
objUser.Put "ipPhone", "5555"
objUser.SetInfo

As for actually cleaning up an existing entry, it's a simple string manipulation function in VBScript.

[1] Retrieve the existing entry in a variable called currentPhone:

[2] Run a string replacement on currentPhone: Replace(currentPhone, " (0)", "")

[3] Set currentPhone as the user's new phone attribute: objUser.Put "homePhone", currentPhone
0
Building an interactive eFuture classroom

Watch and learn how ATEN provided a total control system solution including seamless switching matrix switch, HDBaseT extenders, PDU, lighting control to build an interactive eFuture classroom.

 

Author Comment

by:Yann de Champlain
ID: 18889617
I think it would do it yes.
Thank you.

But indeed, I would need a clean and a little more complete code.
I suppose currentPhone would be the var in a loop to replace all the phone number fields?

Thanks for your code.  The completed version of this will do the trick.
0
 
LVL 30

Accepted Solution

by:
LauraEHunterMVP earned 2000 total points
ID: 18890171
The following script assumes that you want to make this change for every single user in your domain.  If you want to run it on a single OU as a test, just change the DN in the first line from "dc=company,dc=com" to something like "ou=TestOU,dc=company,dc=com"

Option Explicit

dim objParent, objUser, strCurrentPhone,strNewPhone

set objParent = GetObject("LDAP://dc=company,dc=com")
objParent.Filter = Array("user")
for each objUser in objParent
  strCurrentPhone = objUser.Get("homePhone")
  strNewPhone = Replace(strCurrentPhone," (0)","")
  objUser.Put "homePhone", strNewPhone
next

set objParent = nothing
0
 

Author Comment

by:Yann de Champlain
ID: 18891394
Tanks!
0

Featured Post

Manage your data center from practically anywhere

The KN8164V features HD resolution of 1920 x 1200, FIPS 140-2 with level 1 security standards and virtual media transmissions at twice the speed. Built for reliability, the KN series provides local console and remote over IP access, ensuring 24/7 availability to all servers.

Question has a verified solution.

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

Moving your enterprise fax infrastructure from in-house fax machines and servers to the cloud makes sense — from both an efficiency and productivity standpoint. But does migrating to a cloud fax solution mean you will no longer be able to send or re…
New style of hardware planning for Microsoft Exchange server.
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

730 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