Dim objADSysInfo,strUser,objUser,inputPhone,strEngInfo,strEngMsg,strAraInfo,strAraMsg,Result
Dim xmlhttp,httpURL,strDate,strMsg
' Function to display the retrieved information to a user and accept his modification
Function EnterExtension
'Collect AD information from system where the application is executed
Set objADSysInfo = CreateObject("ADSystemInfo")
'Retrieve username of the logged in user
strUser = objADSysInfo.UserName
'Lookup LDAP for other properties of the user
Set objUser = GetObject("LDAP://" & strUser)
'Display the retrieved information to the user
strEngInfo = "Your Name is " & objUser.CN & VbCrLf & VbCrLf & "Telephone Extension is " & objUser.ipPhone & "." & VbCrLf
strEngMsg = " If this is incorrect, enter your extension (only the last four digits Eg. 5159) and click OK. Otherwise click Cancel"
'Accept User's modified extension number
inputPhone=InputBox( strEngInfo & VbCrLf & strEngMsg & VbCrLf & VbCrLf )
End Function
'Function to Process the extension number entered by the user
Function ProcessExtension
'Upload the modified number and useraccount to a php application which can process it
httpURL = "http://servername.domain/TelExtension.php?UName=" + objUser.sAMAccountName + "&UExt=" + inputPhone
Set xmlhttp = CreateObject("Microsoft.XMLHTTP")
xmlhttp.Open "GET", httpURL, false
xmlhttp.Send
strDate = formatDateTime(Now(), vbLongDate)
strMsg = "Your request will be processed by end of " & strDate
MsgBox strMsg,64,"Information Systems Department"
End Function
'Function to trigger an email
Function SendMail
'Launch Outlook
Set MyApp = CreateObject("Outlook.Application")
Set MyItem = MyApp.CreateItem(0) 'olMailItem
With MyItem
.To = "admin@domain.tld"
' Properly set subject so as to filter out mail at the mail client
.Subject = "Request for Extension change :" + objUser.sAMAccountName + "," + inputPhone
.ReadReceiptRequested = False
' Compose body of the Email
.HTMLBody = objUser.sAMAccountName + " was previously " + objUser.ipPhone + " and needs to be modified to " + inputPhone
' Send the mail
.Send
End With
End Function
'Function to Check the validity of extension entered
Function CheckExtension
If IsEmpty(inputPhone) Then
MsgBox strEngInfo & VbCrLf & "Thank You for your cooperation",64,"Information Systems Department"
'This is expected if the user clicks Cancel, i.e. his extension in our records is correct. So Set Flag to 1
Result=1
If (inputPhone > 4000 And inputPhone < 4199) OR (inputPhone > 5000 And inputPhone < 5999) Then
ProcessExtension()
Result=1
Else
strMsg = "Please enter your extension again. Enter only the last four digits.For Eg. 5678 "
MsgBox strMsg,48,"UPDA Information Systems Department"
Result=0
End If
End If
End Function
' Main code Begins here
Result=0
'Run till the user enters a valid number or cancels
Do While Result=0
EnterExtension()
CheckExtension()
Loop
Showing posts with label VBScript active directory lookup mail outlook php upload. Show all posts
Showing posts with label VBScript active directory lookup mail outlook php upload. Show all posts
Tuesday, January 26, 2010
VBScript for Telephone Extension verification by users
This VBScript application identifies a logged on User, retrieves their login name, checks up their telephone number and asks them for a confirmation if its the correct number. If its wrong, it mails the corrected name and number to a particular user and also uploads it to a particular php script. I used this to migrate our users from Cisco Call Manager phone directory to an integrated Active Directory Address book.
Subscribe to:
Posts (Atom)