[cisco-voip] UserID when syncing via ldap.. Removing certaincharacters?

Ryan West rwest at zyedge.com
Fri Apr 4 15:32:17 EDT 2008


I thought this would be very useful after re-reading the post from earlier and realizing that I'll more than likely run into issues where people are using corporate directories for external reasons such as mobile phones that sync to AD and need to the use internal directory for LDAP syncing.  I'm no programmer, as should be clear after seeing my scripts, but they seem to work fine.

This first script will pop up a box and let you know what changes are going to be made.  Warning: on a large domain this could be highly annoying.

<code>

On Error Resume Next

Const ADS_SCOPE_SUBTREE = 2

'set my global regexp
Set re = New regexp
re.Pattern = "[0-9]{4}$"
re.Global = True
re.IgnoreCase = True


Set objConnection = CreateObject("ADODB.Connection")
Set objCommand =   CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnection = objConnection

objCommand.Properties("Page Size") = 1000
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE

objCommand.CommandText = "SELECT AdsPath FROM 'LDAP://dc=zyedge-test,dc=com' WHERE objectCategory='user'"

Set objRecordSet = objCommand.Execute

objRecordSet.MoveFirst

Do Until objRecordSet.EOF
    strUserPath = objRecordSet.Fields("AdsPath").Value
    Set objUser = GetObject(strUserPath)
        Set matches = re.Execute(objUser.telephoneNumber)
        If matches.Count > 0 Then
    Set match = matches(0)
    msg = "Found match """ & match.Value & _
          """ at position " & match.FirstIndex & vbCRLF
    msgbox msg, 0, "VBScript Regular Expression Tester"
  Else

  End If
    objRecordSet.MoveNext
Loop

</code>

If you don't think that script is going to destroy your AD, then you can use the following to actually make the changes:

On Error Resume Next

Const ADS_SCOPE_SUBTREE = 2

Set re = New regexp
re.Pattern = "[0-9]{4}$"
re.Global = True
re.IgnoreCase = True

Set objConnection = CreateObject("ADODB.Connection")
Set objCommand =   CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnection = objConnection

objCommand.Properties("Page Size") = 1000
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE

objCommand.CommandText = "SELECT AdsPath FROM 'LDAP://dc=yourdomain,dc=com' WHERE objectCategory='user'"

Set objRecordSet = objCommand.Execute

objRecordSet.MoveFirst

Do Until objRecordSet.EOF
    strUserPath = objRecordSet.Fields("AdsPath").Value
    Set objUser = GetObject(strUserPath)
    strTelephone = objUser.telephoneNumber
        Set matches = re.Execute(strTelephone)
        Set match = matches(0)
    objUser.IpPhone = match.Value
    objUser.SetInfo
    objRecordSet.MoveNext
Loop

Let me know how it works out for you.  BTW.. make sure you adjust the LDAP bind to reflect your domain.

-ryan

-----Original Message-----
From: cisco-voip-bounces at puck.nether.net [mailto:cisco-voip-bounces at puck.nether.net] On Behalf Of Grisham, Tom
Sent: Friday, April 04, 2008 11:36 AM
To: MILLS, Mark; cisco-voip at puck.nether.net
Subject: Re: [cisco-voip] UserID when syncing via ldap.. Removing certaincharacters?

We had a similar issue, in that 9,000 numbers in the LDAP domain that we
desired to sync call manager with.  Primarily to have a directories link
on the phone so that one-button calling to any of the 9,000 users, ie.
Not to use the "EditDial" soft-key.  With 9,000 numbers the format was
all over the place.

So our AD guru created a script to do the transposing of the AD user
BusinessTelephoneNumber object (held +61(0)884807702 PSTN strings) to
the AD user IPTelephoneNumber object.  In our case this additional phone
number field was empty for all users and we could populate it.  So the
script/stripping logic was homegrown and independent of CUCM.  This then
allowed us to sync CUCM to the IP Phone number field.

Not elegant, but functional.



-----Original Message-----
From: MILLS, Mark [mailto:mark.mills at baesystems.com]
Sent: Friday, April 04, 2008 12:08 AM
To: cisco-voip at puck.nether.net
Subject: [cisco-voip] UserID when syncing via ldap.. Removing
certaincharacters?


Hi,

We are doing Active Directory syncing for CallManager 6 users.

We use the telephoneNumber ldap attribute to map to the User ID field in
CCM, but in AD want to use the full international format such as
"+61(0)884807702" for numbers.

This is obviously a bit horrible for users to enter via their phone, is
there any way possible that we can have it selectively strip out the
+61(0) part of the number when creating the synced User ID's???   Ie, so
the login for the above number would actually be 884807702 ?

I have had a hunt around, and cant seem to find anything about doing
this, so I am assuming its not possible?  :(

Thanks,
   Mark
"Warning:
The information contained in this email and any attached files is
confidential to BAE Systems Australia. If you are not the intended
recipient, any use, disclosure or copying of this email or any
attachments is expressly prohibited.  If you have received this email
in error, please notify us immediately. VIRUS: Every care has been
taken to ensure this email and its attachments are virus free,
however, any loss or damage incurred in using this email is not the
sender's responsibility.  It is your responsibility to ensure virus
checks are completed before installing any data sent in this email to
your computer."



_______________________________________________
cisco-voip mailing list
cisco-voip at puck.nether.net
https://puck.nether.net/mailman/listinfo/cisco-voip


More information about the cisco-voip mailing list