Solved

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

Posted on 2007-04-10
6
488 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
  • 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, PMP
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
NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

 

Author Comment

by:Yann de Champlain, PMP
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 500 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, PMP
ID: 18891394
Tanks!
0

Featured Post

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

Suggested Solutions

Usually shares are where we want them for our users and we tend to take them for granted. There are times, however, when those shares may disappear causing difficulty for your users. One of the first things to try is searching for files that shou…
More or less everybody in the IT market understands the basics of Networking, however when we start talking about Storage Networks, things get a bit dizzier, and this is where I would like to help.
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

770 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