Hey all!
I've been tasked with finding a script that updates user's contact information in the GAL on an Exchange 2k3 environment. Since this task is being delegated, I'm looking for an HTA that will only show the attributes that the account contact manager an change. Below is a script does what I need it to do, but only does it to the users' account that runs it.
I'm a newb at VBScript and I know I'm heading in the right direction with this script. Could someone help me config this script to where I can choose which user to run this against? I can take care of the rest of the code, just need it to connect to my domain controller and give an option to change the user. Any help would be greatly appreciated.
====================================================
<html>
<head>
<title>Contingency Preparedness Assistant v1.0</title>
<HTA:APPLICATION
ID="AScript"
APPLICATIONNAME="Change User Contact Information"
SCROLL="Yes"
SINGLEINSTANCE="yes"
WINDOWSTATE="normal"
BORDER="dialog"
CAPTION="e-Assistant"
>
</head>
<SCRIPT Language="VBScript">
Sub Window_Onload
Set objWshNet = CreateObject("Wscript.Network")
strCN = lcase(objWshNet.ComputerName)
strCU = lcase(objWshNet.UserName)
Dim objFS, objFile, append
append = 8
Const ForWriting = 2
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objLogFile = objFSO.OpenTextFile("access.log", append, True)
objLogFile.WriteLine (strCU & " on " & strCN & " " & Now())
objLogFile.Close
Set objWSHShell = CreateObject("Wscript.Shell")
'36 Msgbox "The application has started."
Set objWSHShell = CreateObject("Wscript.Shell")
' Msgbox "The application has started."
'Set objADSysInfo = CreateObject("ADSystemInfo")
'strUser = objADSysInfo.UserName
strUser = Txt_Username
Set objUser = GetObject("LDAP://" & strUser)
'msgBox "You current object path is: " & strUser
strgivenName = objUser.Get("givenName")
strdisplayName = objUser.Get("displayName")
MsgBox "Hello, " & strgivenName & "!"
OptionLists
'47===================================================================
strMyDC = "MyDomain" & "/"
'strMyDC = My Domain Controller
Set objADSysInfo = CreateObject("ADSystemInfo")
strUser = strUsername
Set objItem = GetObject("LDAP://" & strMyDC & strUser)
On Error Resume Next
'GetInfo
strStreetAddress = objItem.Get("streetAddress")
strPOBOX = objItem.Get("postOfficeBox")
strCity = objItem.Get("l")
strZIP = objItem.Get("postalCode")
strTelephoneNumber = objItem.Get("telephoneNumber")
strMobile = objItem.Get("mobile")
strTitle = objItem.Get("title")
'62 WriteInfo
Txt_Add.Value = strStreetAddress
'Txt_POBox.Value = strPOBOX
Txt_City.Value = strCity
Txt_ZIP.Value = strZIP
Txt_PhN.Value = strTelephoneNumber
Txt_Cell.Value = strMobile
Txt_Title.Value = strTitle
Txt_User.Value = strUsername
End Sub
Sub OptionLists
'73====================================================================
'====================================================================
End Sub
Sub Update
'Set objADSysInfo = CreateObject("ADSystemInfo")
'strUser = objADSysInfo.UserName
strUser = Txt_Username
Set objItem = GetObject("LDAP://mfaoil/" & strUser)
On Error Resume Next
objItem.Put "streetAddress", Txt_Add.Value
objItem.Put "l", Txt_City.Value
objItem.Put "PostalCode", Txt_ZIP.Value
objItem.Put "TelephoneNumber", Txt_PhN.Value
objItem.Put "mobile", Txt_Cell.Value
objItem.SetInfo
'Line 85
msgbox "Thank you, your information has been saved."
End Sub
'Sub PrintThis
' Window.Print()
'End Sub
</SCRIPT>
<body>
<body STYLE="font:12pt arial; color:black;
filterrogidXImageTransform.Microsoft.Gradient
(GradientType=0, StartColorStr='#FFF0F5', EndColorStr='#FAFAD2')">
<hr>
To use this Assistant enter the requested information and press 'Update' once you have finished.<br> <br>
<p>
User: <br> <input type="text" name="Txt_Username" size="50"><br><br>
Address:<br> <input type="text" name="Txt_Add" size="50"><br><br>
City:<br> <input type="text" name="Txt_City" size="50"><br><br>
Zip Code:<br> <input type="text" name="Txt_ZIP" size="50"><br><br>
Cell Phone: <font color="red" face="Arial" size="2">Example: (417) 123-4567</font><br> <input type="text" name="Txt_Cell" size="50"><br><br>
Telephone: <font color="red" face="Arial" size="2">Example: (417) 123-4567</font><br> <input type="text" name="Txt_PhN" size="50"><br><br>
Title:<br> <input type="text" name="Txt_Title" size="50"><br><br>
<hr>
<input id=runbutton class="button" type="button" value="Print" name="PrintNow" onClick="PrintThis">
<input id=runbutton class="button" type="button" value="Update" name="UpdateInf" onClick="Update"><br><br>
<BUTTON onclick="window.close()">Quit</BUTTON>
</body>
</html>
==========================================================
Shon
Network Admin
Shon
Network Administrator
I've been tasked with finding a script that updates user's contact information in the GAL on an Exchange 2k3 environment. Since this task is being delegated, I'm looking for an HTA that will only show the attributes that the account contact manager an change. Below is a script does what I need it to do, but only does it to the users' account that runs it.
I'm a newb at VBScript and I know I'm heading in the right direction with this script. Could someone help me config this script to where I can choose which user to run this against? I can take care of the rest of the code, just need it to connect to my domain controller and give an option to change the user. Any help would be greatly appreciated.
====================================================
<html>
<head>
<title>Contingency Preparedness Assistant v1.0</title>
<HTA:APPLICATION
ID="AScript"
APPLICATIONNAME="Change User Contact Information"
SCROLL="Yes"
SINGLEINSTANCE="yes"
WINDOWSTATE="normal"
BORDER="dialog"
CAPTION="e-Assistant"
>
</head>
<SCRIPT Language="VBScript">
Sub Window_Onload
Set objWshNet = CreateObject("Wscript.Network")
strCN = lcase(objWshNet.ComputerName)
strCU = lcase(objWshNet.UserName)
Dim objFS, objFile, append
append = 8
Const ForWriting = 2
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objLogFile = objFSO.OpenTextFile("access.log", append, True)
objLogFile.WriteLine (strCU & " on " & strCN & " " & Now())
objLogFile.Close
Set objWSHShell = CreateObject("Wscript.Shell")
'36 Msgbox "The application has started."
Set objWSHShell = CreateObject("Wscript.Shell")
' Msgbox "The application has started."
'Set objADSysInfo = CreateObject("ADSystemInfo")
'strUser = objADSysInfo.UserName
strUser = Txt_Username
Set objUser = GetObject("LDAP://" & strUser)
'msgBox "You current object path is: " & strUser
strgivenName = objUser.Get("givenName")
strdisplayName = objUser.Get("displayName")
MsgBox "Hello, " & strgivenName & "!"
OptionLists
'47===================================================================
strMyDC = "MyDomain" & "/"
'strMyDC = My Domain Controller
Set objADSysInfo = CreateObject("ADSystemInfo")
strUser = strUsername
Set objItem = GetObject("LDAP://" & strMyDC & strUser)
On Error Resume Next
'GetInfo
strStreetAddress = objItem.Get("streetAddress")
strPOBOX = objItem.Get("postOfficeBox")
strCity = objItem.Get("l")
strZIP = objItem.Get("postalCode")
strTelephoneNumber = objItem.Get("telephoneNumber")
strMobile = objItem.Get("mobile")
strTitle = objItem.Get("title")
'62 WriteInfo
Txt_Add.Value = strStreetAddress
'Txt_POBox.Value = strPOBOX
Txt_City.Value = strCity
Txt_ZIP.Value = strZIP
Txt_PhN.Value = strTelephoneNumber
Txt_Cell.Value = strMobile
Txt_Title.Value = strTitle
Txt_User.Value = strUsername
End Sub
Sub OptionLists
'73====================================================================
'====================================================================
End Sub
Sub Update
'Set objADSysInfo = CreateObject("ADSystemInfo")
'strUser = objADSysInfo.UserName
strUser = Txt_Username
Set objItem = GetObject("LDAP://mfaoil/" & strUser)
On Error Resume Next
objItem.Put "streetAddress", Txt_Add.Value
objItem.Put "l", Txt_City.Value
objItem.Put "PostalCode", Txt_ZIP.Value
objItem.Put "TelephoneNumber", Txt_PhN.Value
objItem.Put "mobile", Txt_Cell.Value
objItem.SetInfo
'Line 85
msgbox "Thank you, your information has been saved."
End Sub
'Sub PrintThis
' Window.Print()
'End Sub
</SCRIPT>
<body>
<body STYLE="font:12pt arial; color:black;
filterrogidXImageTransform.Microsoft.Gradient
(GradientType=0, StartColorStr='#FFF0F5', EndColorStr='#FAFAD2')">
<hr>
To use this Assistant enter the requested information and press 'Update' once you have finished.<br> <br>
<p>
User: <br> <input type="text" name="Txt_Username" size="50"><br><br>
Address:<br> <input type="text" name="Txt_Add" size="50"><br><br>
City:<br> <input type="text" name="Txt_City" size="50"><br><br>
Zip Code:<br> <input type="text" name="Txt_ZIP" size="50"><br><br>
Cell Phone: <font color="red" face="Arial" size="2">Example: (417) 123-4567</font><br> <input type="text" name="Txt_Cell" size="50"><br><br>
Telephone: <font color="red" face="Arial" size="2">Example: (417) 123-4567</font><br> <input type="text" name="Txt_PhN" size="50"><br><br>
Title:<br> <input type="text" name="Txt_Title" size="50"><br><br>
<hr>
<input id=runbutton class="button" type="button" value="Print" name="PrintNow" onClick="PrintThis">
<input id=runbutton class="button" type="button" value="Update" name="UpdateInf" onClick="Update"><br><br>
<BUTTON onclick="window.close()">Quit</BUTTON>
</body>
</html>
==========================================================
Shon
Network Admin
Shon
Network Administrator