Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Anyway to Export AD User info to change phone # ? 2

Status
Not open for further replies.

pctekkk

MIS
Dec 9, 2004
57
US
Is there an easy way to export a list of all users in AD
so we can change how their phone #'s are listed, then Reimport back in ??

reason is we use Blackberry and
originally setup

x234 DID 650-343-1234

so when u dial from blackberry, it trys to dial x234 first DID and of course doesnt work.

so we want to change to
650-343-1234

so easier to dial
thanks
 
yes, this can be done via a script.

Retrieve User Telephone Properties
Code:
On Error Resume Next
Set objUser = GetObject _
  ("LDAP://cn=myerken,ou=management,dc=fabrikam,dc=com")
objUser.GetInfo

strHomePhone = objUser.Get("homePhone")
strPager = objUser.Get("pager")
strMobile = objUser.Get("mobile")
strIpPhone = objUser.Get("ipPhone")
strInfo = objUser.Get("info")
strFacsimileTelephoneNumber = _
  objUser.Get("facsimileTelephoneNumber")

strOtherHomePhone = objUser.GetEx("otherHomePhone")
strOtherPager = objUser.GetEx("otherPager")
strOtherMobile = objUser.GetEx("otherMobile")
strOtherIpPhone = objUser.GetEx("otherIpPhone")
strOtherFacsimileTelephoneNumber = _
	objUser.GetEx("otherFacsimileTelephoneNumber")

WScript.echo "homePhone: " & strHomePhone
WScript.echo "pager: " & strPager
WScript.echo "mobile: " & strMobile
WScript.echo "ipPhone: " & strIpPhone
WScript.echo "info: " & strInfo
WScript.echo "facsimileTelephoneNumber: " & _
 strFacsimileTelephoneNumber

For Each strValue in strOtherHomePhone
  WScript.echo "otherHomePhone: " & strValue
Next
For Each strValue in strOtherPager
  WScript.echo "otherPager: " & strValue
Next
For Each strValue in strOtherMobile
  WScript.echo "otherMobile: " & strValue
Next
For Each strValue in strOtherIpPhone
  WScript.echo "otherIpPhone: " & strValue
Next
For Each strValue in strOtherFacsimileTelephoneNumber
  WScript.echo "otherFacsimileTelephoneNumber: " & strValue
Next

Configure User Telephoen Properties
Code:
Const ADS_PROPERTY_UPDATE = 2 
Set objUser = GetObject _
   ("LDAP://cn=myerken,ou=management,dc=fabrikam,dc=com") 

objUser.Put "homePhone", "(425) 555-1111"
objUser.Put "pager", "(425) 555-2222"
objUser.Put "mobile", "(425) 555-3333"
objUser.Put "facsimileTelephoneNumber", "(425) 555-4444"   
objUser.Put "ipPhone", "5555"
objUser.Put "info", "Please do not call this user account" & _
  " at home unless there is a work-related emergency. Call" & _
  " this user's mobile phone before calling the pager number"

objUser.PutEx ADS_PROPERTY_UPDATE, _
    "otherHomePhone", Array("(425) 555-1112")
objUser.PutEx ADS_PROPERTY_UPDATE, _
    "otherPager", Array("(425) 555-2223")
objUser.PutEx ADS_PROPERTY_UPDATE, _
    "otherMobile", Array("(425) 555-3334", "(425) 555-3335")
objUser.PutEx ADS_PROPERTY_UPDATE, _
    "otherFacsimileTelephoneNumber", Array("(425) 555-4445")
objUser.PutEx ADS_PROPERTY_UPDATE, _
    "otherIpPhone", Array("6666")

objUser.SetInfo


I hope you find this post helpful. Please let me know if it was.

Regards,

Mark
 
You can use LDIFDE or CSVDE to do the export, then LDIFDE to do the import.

First, I'll tell you the format for the input file for LDIF... It must be in this format for each individual change made to the AD Database...

[blue]dn: CN=User,OU=ouname,DC=domain,DC=tld
changetype: modify
replace: telephoneNumber
telephoneNumber: 650-343-1234
-[/blue]

The "-" is a delimeter between individual changes. Modify the dn: field as appropriate. You'll see when you do your export.

How to export:
LDIFDE -f c:\[blue]yourdumpfile.txt[/blue] -l "telephoneNumber" -r "(&(objectClass=user)(objectCategory=person))"

Your output will look something like this:
[blue]dn: CN=user1,CN=Users,DC=domain,DC=tld
changetype: add
telephoneNumber: x234 DID <blah>

dn: CN=user2,OU=ouname,DC=domain,DC=tld
changetype: add
telephoneNumber: x234 DID <blah>[/blue]

You need to modify the changetype: to modify as above, then add the line "replace: ..." as above, and the -.

[red]OR[/red]

You can use CSVDE to do the extract and then modify all the phone numbers in excel. The thing is... you have to do the import with LDIFDE using the format listed above. A simple VB script can do it, it's up to you.

[red]CSVDE[/red] -f c:\[blue]yourdumpfile.[red]csv[/red][/blue] -l "telephoneNumber" -r "(&(objectClass=user)(objectCategory=person))"


PSC

Governments and corporations need people like you and me. We are samurai. The keyboard cowboys. And all those other people out there who have no idea what's going on are the cattle. Mooo! --Mr. The Plague, from the movie "Hackers
 
Thank You gentlemen, will try this weekend !!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top