Solved

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

Posted on 2007-04-10
6
491 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
[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, 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
Flexible connectivity for any environment

The KE6900 series can extend and deploy computers with high definition displays across multiple stations in a variety of applications that suit any environment. Expand computer use to stations across multiple rooms with dynamic access.

 

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

Connect further...control easier

With the ATEN CE624, you can now enjoy a high-quality visual experience powered by HDBaseT technology and the convenience of a single Cat6 cable to transmit uncompressed video with zero latency and multi-streaming for dual-view applications where remote access is required.

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…
Data center, now-a-days, is referred as the home of all the advanced technologies. In-fact, most of the businesses are now establishing their entire organizational structure around the IT capabilities.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

751 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