Web Script stopped working
This used to work fine, but for the past week has been failing. Intent is
to open a page called USER.htm where USER is someone's userid. Is there an
error in my old script, or could it be that IE7 being automagically
installed on the web server screwed it up somehow, or what? Any ideas?
Here is the script, which is at the top of an asp file, that takes in the
info:
<%@ Language="VBScript" %>
<%
Set obj = Server.CreateObject("iisPROTECTadmin.admin")
obj.ReloadAccess()
obj.ReloadSettings()
page = request("page")
if ( Request.form("user") <> "" AND Request.form("password") <> "") Then
Response.Cookies("IISPROTECTLOGIN")("USER") = Request.form("user")
encdata = obj.Encrypt( Request.form("password") )
Response.Cookies("IISPROTECTLOGIN")("PW") = encdata
if (Request.Cookies("IISPROTECTLOGIN")("SID") = "") then
response.Cookies("IISPROTECTLOGIN")("SID") = obj.sid
end if
Response.Cookies("IISPROTECTLOGIN").expires = date()+ 365
'Response.Cookies("IISPROTECTLOGIN").Path="/"
if Request.Cookies("IISPROTECTLOGIN").HasKeys then
if (page <> "" ) then
Response.Redirect page
end if
end if
end if
set obj = nothing
%> Tag: onmouseover and onmouseout considered acceptable in standards? Tag: 211446
Tick the "For fast searching" box in folder properties
I am involved in scripting an XP workstation add to an Active Directory
domain. This includes setting up Windows Desktop Search. On the image
deployed to all the workstations the "For fast searching, allow Indexing
Service to index this folder" attribute has been unchecked on all folders.
For WDS to function this box must be checked. This attribute can be found by
going to properties of any folder and clicking the Advanced button on the
General tab. I can script ticking or unticking a couple other attributes on
the page, but am unable to find a way for this specific property. Does
anyone have any insight to offer? Thanks for your help!
Tony Tag: onmouseover and onmouseout considered acceptable in standards? Tag: 211444
Need to delete files in the RECYCLER bin deleted older then a certain date
For deleting files from anywhere else, I can just use the "datalastmodified"
property to tell if a file is old enough for me to decide to delete. I was
hoping there was a property for the date the file was deleted, like called
"datedeleted" or something, but I can't find any documentation on that, or
method to achieve this some other way. Anyone have an idea? Tag: onmouseover and onmouseout considered acceptable in standards? Tag: 211442
Monitor SSL certificate
I need a script which can give me details of X.509 SSL certificate expiry date.
I need to run this script remotely for different servers.
It will be very helpfull if somebody can provide is some script or a tool. Tag: onmouseover and onmouseout considered acceptable in standards? Tag: 211440
Error 800703E6 in VBscript
Hi - I am stumped with this error, and would appreciate any insights. I have
a VBscript that is running on approximately 500 computers. The specific
routine in question is to start a service (pcAnywhere Host) on the computer.
This works more than 99% of the time. However, each day, a random computer
has the 800703E6 - Invalid access to memory location error. I have not found
anything unusual about the computer or the pcAnywhere service on the computer
when this happens.
A bit more background:
All PC's have Windows XP
Scripts are run under a local admin account (same account on all PC's)
Rebooting the computer and running the script again results in no error
I am pasting the specific routine below where this error occurs. The error
references the line "For Each..."
strComputer = "."
strService = " 'awhost32' "
Set objWMIService =
GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
Set colListOfServices = objWMIService.ExecQuery ("Select * from
Win32_Service Where Name =" & strService & " ")
For Each objService in colListOfServices
objService.StartService()
if bRunEntireScript then 'only writes to database if the full
script is running
DatabaseInsert "PCAnywhereStatus", objService.State,
objService.Status
DatabaseInsert "PCAnywhereRestart", objService.Name, err.Number
end if
Next
Thank you for your assistance.
Mike Tag: onmouseover and onmouseout considered acceptable in standards? Tag: 211438
Newbie needs help w/ simple script ...
Hi guys,
I'm trying to create a simple script to backup some of our files with
WinZip. I think the trouble that I'm having is that the path has space
in it and I can't quite handle it correctly.
I want to grab the current date and I think this is working correctly.
dtmToday = Date()
Wscript.Echo dtmToday
Then I want to create a zip file using the current date in the
filename. The path to WinZip to do this is:
C:\Program Files\WinZip\WINZIP32.EXE" -min -a -r -p -hs c:\tmp
\backup1_test.zip C:\some dir
Except instead of "backup1_test.zip" I would like the filename to be
similar to:
10.25.07_MyArchive.zip
Can anyone give me a hand with this? I imagine this is a trivial
exercise for most of you. ;-)
I'm off to Borders this afternoon to grab a VBScript reference.
Thanks very much in advance!
Chris
http://amateureconblog.blogspot.com/ Tag: onmouseover and onmouseout considered acceptable in standards? Tag: 211437
Install a printer
Hi.
How can I install a printer in black and white by default by means of a
script?
Regards Tag: onmouseover and onmouseout considered acceptable in standards? Tag: 211432
How to press OK
I have a script that checks the registry to see if a certain key exist. If it
does not, the script then calls an executable via .bat. Once the executabe is
installed, the .bat is set to update a few user settings on the machine.
However, upon completion of the executable, the user is required to select OK
or Finish before the .bat can continue.
Is there a way to have the vbs select OK or Finish for the user so it and/or
the .bat can continue on their way? Tag: onmouseover and onmouseout considered acceptable in standards? Tag: 211431
psexec and double quotes
I want to use the following psexec statement in my script:
psexec \\047-GRAPEVINE "C:\Program Files\Microsoft
Office\Office\Powerpnt.exe" /s C:\grapevine\ & filename & ".ppt"
Because I have to wrap parameters in double quotes, do I double the quotes
around the whole statement like this:
'Run the PowerPoint presentation on the 047-GRAPEVINE computer using
psexec.exe
WShell.Run ""psexec \\047-GRAPEVINE "C:\Program Files\Microsoft
Office\Office\Powerpnt.exe" /s C:\grapevine\ & filename & ".ppt""" Tag: onmouseover and onmouseout considered acceptable in standards? Tag: 211429
psexec and double quotes
I want to use the following psexec statement in my script:
psexec \\047-GRAPEVINE "C:\Program Files\Microsoft
Office\Office\Powerpnt.exe" /s C:\grapevine\ & filename & ".ppt"
Because I have to wrap parameters in double quotes, do I double the quotes
around the whole statement like this:
'Run the PowerPoint presentation on the 047-GRAPEVINE computer using
psexec.exe
WShell.Run ""psexec \\047-GRAPEVINE "C:\Program Files\Microsoft
Office\Office\Powerpnt.exe" /s C:\grapevine\ & filename & ".ppt""" Tag: onmouseover and onmouseout considered acceptable in standards? Tag: 211428
sizes of all "My documents" folders on all PCs
Hi,
I want to find the sizes of all "My documents" folders on all PCs (in a
domain). Is there a script that cando this job?
Thanks in advance. Tag: onmouseover and onmouseout considered acceptable in standards? Tag: 211427
IIS Configuration
I am always recreating my IIS virtual directories on to other servers. Is
there an automated way I can recreate entire IIS virtual directory structure
using export and import features of IIS? Any samples/articles would be
great! Tag: onmouseover and onmouseout considered acceptable in standards? Tag: 211421
Open a PDF file; execute a hyperlink
I need example VBScript that opens a PDF file (a Reader file); can someone
please post something like that?
Also, I'm assuming you must specify the path - is Acrobat always installed
in the same path, or is there a generic way to open the app?
Is there a way to execute a hyperlink that resides or is defined inside the
same VBScript file? For example, in MS-Excel you can use the following:
ActiveWorkbook.FollowHyperlink Address:=MyFullPath
Thanks much in advance for your assistance. Tag: onmouseover and onmouseout considered acceptable in standards? Tag: 211418
enumerate open files IADsFileServiceOperations Interface
Having some trouble finding information about this one. People seem to
have ideas about enumerating open files or enumerating open sessions,
but does anyone know a way to combine the two??
I am looking for a way to enumerate open files on a server and their
corresponding session (or originating system)
The IADsSession and IADsResource Interfaces are not inherently clear
about doing this. Anyone have any ideas?
Thanks!
Tim Tag: onmouseover and onmouseout considered acceptable in standards? Tag: 211417
Rename a set of files by file ext using increment from another file
I'm a gross vb newbie - I'm working on that though.
I have several files in folder c:\data\2Rename
File1.Grn
File2.Grn
File3.Blu
I have files corresponding to their extension that hold the current file
count:
Grn.seq (1 record, value 223)
Blu.seq (1 record, value 489)
For each file in the c:\data\2Rename folder I want to rename the current file
based on the extension and the sequence in the .seq file corresponding to
the extension, then increment the contents of the seq file
ren File1.Grn New223.grn
increment the value in Grn.seq to 224
Believe it or not it's not too hard in a DOS batch, but I really need to
start doing things in vb script.
Anybody care to take a stab?
Any help would be MUCH appreciated. Tag: onmouseover and onmouseout considered acceptable in standards? Tag: 211413
Finding CD drive in script
Hello,
I use a combination of vbs and batch files in my unattended deployment
of Windows Server 2003. I use the following command in my batch files
to find a cd.txt file on the root of the install CD so I can reference
the path dynamically. It is:
FOR %%i IN (D E F G H I J K L M N O P Q R S T U V W X Y Z) DO IF EXIST
%%i:\CD.txt SET CDROM=%%i:
Unfortunately, I do not know how to perform this inside a vbs file
that I use to determine what hardware the server is and insert a line
in my runonceex later on. The problem is that I have to hard code the
script to use d:\postinstall... as I don't know how to peform the
above FOR/EXIST statement inside the vbs. Is what I am trying to do
possible? I appreciate any insight into this.
The code is as follows:
------------------------------------
'---Start script.vbs---
Option Explicit
'#Declare Variables#
Dim objWMIService,strComputer
Dim colSettings,objComputer
Dim strManufacturer,strModel,objShell
Dim objRegExp
'#Expression Search Info since Dells are whack#
Set objRegExp = New RegExp
objRegExp.IgnoreCase = True
objRegExp.Pattern = "^Dell"
Dim strStringToSearch
'#Define Constants#
'COMMENT: Put your Manufacturer here
'Const MFG1 = "Dell"
Const MFG2 = "IBM"
Const MFG3 = "VMware, Inc."
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root
\cimv2")
Set colSettings = objWMIService.ExecQuery _
("Select * from Win32_ComputerSystem")
For Each objComputer in colSettings
strManufacturer = objComputer.Manufacturer
strStringToSearch = strManufacturer
Next
If objRegExp.Test(strStringToSearch) = True Then
Set objShell = CreateObject("WScript.Shell")
objShell.RegWrite "HKLM\Software\Microsoft\Windows\CurrentVersion
\RunOnceEx\047\","Dell OpenManage Install","REG_SZ"
objShell.RegWrite "HKLM\Software\Microsoft\Windows\CurrentVersion
\RunOnceEx\047\1","d:\postinstall\DELLOM\openinstall.cmd","REG_SZ"
ElseIf strManufacturer = MFG2 Then
Set objShell = CreateObject("WScript.Shell")
objShell.RegWrite "HKLM\Software\Microsoft\Windows\CurrentVersion
\RunOnceEx\047\","IBM Director Install","REG_SZ"
objShell.RegWrite "HKLM\Software\Microsoft\Windows\CurrentVersion
\RunOnceEx\047\1","d:\postinstall\IBM\IBMinstall.cmd","REG_SZ"
ElseIf strManufacturer = MFG3 Then
Set objShell = CreateObject("WScript.Shell")
objShell.RegWrite "HKLM\Software\Microsoft\Windows\CurrentVersion
\RunOnceEx\047\","VMware Tools Install","REG_SZ"
objShell.RegWrite "HKLM\Software\Microsoft\Windows\CurrentVersion
\RunOnceEx\047\1","d:\postinstall\vmware\vmmap.cmd","REG_SZ"
objShell.RegWrite "HKLM\Software\Microsoft\Windows\CurrentVersion
\RunOnceEx\048\","VMware Tools Hardware Acceleration","REG_SZ"
objShell.RegWrite "HKLM\Software\Microsoft\Windows\CurrentVersion
\RunOnceEx\048\1","d:\postinstall\sethw_accel.cmd","REG_SZ"
End If
'---End script.vbs--- Tag: onmouseover and onmouseout considered acceptable in standards? Tag: 211408
please i want script to make ip assigned by dhcp
i used this script to change ip :-
strComputer = "."
Set objWMIService = GetObject( _
"winmgmts:\\" & strComputer & "\root\cimv2")
Set colNetAdapters = objWMIService.ExecQuery _
("Select * from Win32_NetworkAdapterConfiguration " _
& "where IPEnabled=TRUE")
strIPAddress = Array("192.168.1.141")
strSubnetMask = Array("255.255.255.0")
strGateway = Array("192.168.1.100")
strGatewayMetric = Array(1)
For Each objNetAdapter in colNetAdapters
errEnable = objNetAdapter.EnableStatic( _
strIPAddress, strSubnetMask)
errGateways = objNetAdapter.SetGateways(_
strGateway, strGatewaymetric)
Next
please
i want script to make ip assigned by dhcp again
thank you Tag: onmouseover and onmouseout considered acceptable in standards? Tag: 211404
Parameters in quotes treated as one
Hello. I need to acomplish a task, but I have no idea how to do it.
My script has to pass some text into email.
Set collArg = WScript.Arguments
Dim mail
mail = collArg(0)
Dim topic
topic = collArg(1)
Dim body
body = collArg(2)
Set WshShell = WScript.CreateObject("WScript.Shell")
strCommand = "mailto:" & mail & "&subject=" & topic & "&body=" & body
WshShell.Run strcommand
The thing is that parameters like Subject and Body will have spaces.
Parameters then will be passed in "quotes" and they should be treated
as one parameter. How can I do it? Tag: onmouseover and onmouseout considered acceptable in standards? Tag: 211403
Lopping delete row and remove CRLF
Hi all,
I've got 2 codes from previous message posts but need to combine them.
The first bit removes the last 2 characters but only does for one
line, how would I loop it to do many lines so no CRLF (and still
remains in it's orginal layout).
The section bit deletes rows beginning with 345.
I've tried to combine the two but no luck.
Thanks,
Ed
'removes carriage returns and line feeds
Const ForReading = 1
Const ForWriting = 2
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("C:\abc.10", ForReading)
strFile = objFile.ReadAll
objFile.Close
intLength = Len(strFile)
strFile = Left(strFile, intLength - 2)
Set objFile = objFSO.OpenTextFile("C:\abc.10", ForWriting)
objFile.Write strFile
objFile.Close
'********************************************************************
'deletes line beginning with 345
strFileName = "C:\scripts\test.txt"
strCheckForString = UCase("345")
Set objFS = CreateObject("Scripting.FileSystemObject")
Set objTS = objFS.OpenTextFile(strFileName, FOR_READING)
strContents = objTS.ReadAll
objTS.Close
arrLines = Split(strContents, vbNewLine)
Set objTS = objFS.OpenTextFile(strFileName, FOR_WRITING)
For Each strLine In arrLines
If Not(Left(UCase(LTrim(strLine)),Len(strCheckForString)) =
strCheckForString) Then
objTS.WriteLine strLine
End If
Next Tag: onmouseover and onmouseout considered acceptable in standards? Tag: 211402
hello - and thanks to all that helped me!
This group, whether by me simply searching for answers for posting
looking for them, has been super super helpful in creating my campus-
wide inventory script. I now have a SQL database populating with
information as folks log in, getting everything from serial number to
model name to hard drive, etc. I want to post my full inventory
script here, so anyone who has been wanting to do something like this
can simply copy/paste and modify as needed! So thanks again, and
copy, modify and enjoy :-)
On Error Resume Next
Const HKEY_LOCAL_MACHINE = &H80000002
DIM strComputerName
strComputer = "."
Set objReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &
_
strComputer & "\root\default:StdRegProv")
strKeyPath = "SOFTWARE\ODBC\ODBC.INI\ODBC Data Sources"
strValueName = "Inventory"
strValue = "SQL Server"
objReg.SetStringValue
HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue
strKeyPath = "SOFTWARE\ODBC\ODBC.INI\Inventory"
objReg.CreateKey HKEY_LOCAL_MACHINE,strKeyPath
strKeyPath = "SOFTWARE\ODBC\ODBC.INI\Inventory"
strValueName = "Database"
strValue = "Inventory"
objReg.SetStringValue
HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue
strValueName = "Driver"
strValue = "C:\WINDOWS\System32\SQLSRV32.dll"
objReg.SetStringValue
HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue
strValueName = "Server"
strValue = "CERBERUS"
objReg.SetStringValue
HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue
strValueName = "Trusted_Connection"
strValue = "Yes"
objReg.SetStringValue
HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue
Const adOpenStatic = 3
Const adLockOptimistic = 3
Const adUseClient = 3
Set objConnection = CreateObject("ADODB.Connection")
Set objRecordset = CreateObject("ADODB.Recordset")
objConnection.Open "DSN=Inventory;"
objRecordset.CursorLocation = adUseClient
objRecordset.Open "SELECT * FROM Hardware" , objConnection, _
adOpenStatic, adLockOptimistic
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer& "\root
\cimv2")
Set colSettings = objWMIService.ExecQuery _
("SELECT * FROM Win32_ComputerSystem")
For Each objComputer in colsettings
strComputerName = objComputer.Name
Next
strSearchCriteria = "CompName ='" & strComputerName & "'"
objRecordset.Find strSearchCriteria
IF objRecordset.EOF = True Then
Set colSettings = objWMIService.ExecQuery _
("SELECT * FROM Win32_ComputerSystem")
For Each objComputer in colsettings
objRecordset.AddNew
objRecordset("CompName") = objComputer.Name
objRecordset.Update
Next
call subwritedata
Else
call subwritedata
End If
objRecordset.Close
objConnection.Close
WScript.Quit
'
' Beneath here be Subroutines
'
Sub subwritedata
Set colSettings = objWMIService.ExecQuery _
("SELECT * FROM Win32_ComputerSystem")
For Each objComputer in colsettings
objRecordSet("Memory") = round(objComputer.TotalPhysicalMemory/1024)
& " MB"
objRecordset.Update
Next
Set colSettings = objWMIService.ExecQuery _
("SELECT * FROM Win32_OperatingSystem")
For Each objOperatingSystem in colSettings
objRecordset("OS") = objOperatingSystem.Caption
objRecordset.Update
Next
Set colSettings = objWMIService.ExecQuery _
("SELECT * FROM Win32_Processor")
For Each objCPU in colSettings
objRecordset("Processor") = trim(objCPU.Name)
objRecordset.Update
Next
Set colSettings = objWMIService.ExecQuery _
("SELECT * FROM Win32_DiskDrive")
For Each objDisk in colSettings
objRecordset("HardDrive") = round(objDisk.Size/1000000000) & " GB"
objRecordset.Update
Next
Set colSettings = objWMIService.ExecQuery _
("SELECT * FROM Win32_ComputerSystem")
For Each objComputer in colsettings
objRecordSet("CompType") = objComputer.Model
objRecordset.Update
Next
Set colsettings = objWMIService.ExecQuery _
("SELECT * FROM Win32_BIOS")
For Each ObjBIOS in colsettings
objRecordset("Serial") = objBios.SerialNumber
objRecordset.Update
Next
Set colChassis = objWMIService.ExecQuery _
("Select * from Win32_SystemEnclosure")
For Each objChassis in colChassis
For Each strChassisType in objChassis.ChassisTypes
If strChassisType = 8 THEN
objRecordset("Chassis") = "Laptop"
ElseIf strChassisType = 9 THEN
objRecordset("Chassis") = "Laptop"
ElseIf strChassisType = 10 THEN
objRecordset("Chassis") = "Laptop"
ElseIf strChassisType = 12 THEN
objRecordset("Chassis") = "Laptop"
ElseIf strChassisType = 13 THEN
objRecordset("Chassis") = "Laptop"
ELSE
objRecordset("Chassis") = "Desktop"
End If
objRecordset.Update
Next
Next
Set colsettings = objWMIService.ExecQuery _
("SELECT * FROM Win32_BIOS")
For Each ObjBIOS in colsettings
objRecordset("ReleaseDate") = left(objBios.ReleaseDate,8)
objRecordset.Update
Next
Set colSettings = objWMIService.ExecQuery _
("SELECT * FROM Win32_ComputerSystem")
For Each objItem in colSettings
arrName = Split(objItem.UserName, "\")
objRecordset("Login") = arrName(1)
objRecordset.Update
Next
Set colItems = objWMIService.ExecQuery _
("Select * From Win32_NetworkAdapterConfiguration " & _
"Where IPEnabled = True")
For Each objItem in colItems
For Each objAddress in objItem.IPAddress
objRecordset("IP") = objAddress
objRecordset.Update
Next
Next
Set colItems = objWMIService.ExecQuery _
("Select * From Win32_NetworkAdapterConfiguration " & _
"Where IPEnabled = True")
For Each objAdapter in colItems
objrecordset("Mac") = objAdapter.MacAddress
objRecordset.Update
Next
objRecordset("Date") = Date()
objRecordset.Update
objRecordset("Time") = Time()
objRecordset.Update
End Sub Tag: onmouseover and onmouseout considered acceptable in standards? Tag: 211400
Defrag Hard Disks
I am using the following script to automate the defrag of all volumes
on a server, is it possible to make the script wait and not exit until
the defrag is complete. This is destined to become the last part of a
"first boot" script used in server deployment so I would like to have
the script initiate a reboot once this is finished.
'execute against the local computer
strComputer = "."
'connect to the WMI service on strComputer
Set objWMIService = GetObject("winmgmts:" &
"{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
'Defrag All Hard disks
Set colVolumes = objWMIService.ExecQuery ("Select * from
Win32_Volume")
For Each objVolume in colVolumes
errResult = objVolume.Defrag()
Next
Thanks,
Josh Tag: onmouseover and onmouseout considered acceptable in standards? Tag: 211399
Install a printer in black and white
Hi.
How can I install a printer in black and white by default by means of a
script?
Regards Tag: onmouseover and onmouseout considered acceptable in standards? Tag: 211392
Selecting current week in drop down
Hi All,
In a drop down box i am populating all the weeks from 1 to 52, but
whenever the page loads, i want it show the current week number as
selected value.
Below is what is did:
<option selected value="<% DatePart("ww", Now()) %>"> <% wkCnt %> </
option>
But when my page loads, the drop down box shows the last week in the
list (52), instead of current week which is 43.
please let me know i am missing something.
appreciate any ideas on this.
Thank you!!
Navin Tag: onmouseover and onmouseout considered acceptable in standards? Tag: 211391
Do not support HTML in textarea - on server-side
Hi,
I have a textarea and I would like to prevent users from inserting
HTML tags. Only plain text is supported.
Which server-side vbscript regular expression is best for this?
Thanks, Gabi Tag: onmouseover and onmouseout considered acceptable in standards? Tag: 211390
Help Splitting a String
Can anyone help me please.
I am trying to split a users homedrive which I input using the
following code, the problem is I get an error when trying to split the
name. I basically want to get the servername and the home drive share
name as two seperate values so I can then use them seperatly.
The Home drive is displayed as "\\Servername\Sharename$"
username = "HJSimpson"
Const ADS_PROPERTY_DELETE = 4
Const ADS_PROPERTY_APPEND = 3
'Open connection to AD using LDAP
Set objCommand = CreateObject("ADODB.Command")
Set objConnection = CreateObject("ADODB.Connection")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
objCommand.ActiveConnection = objConnection
strBase = "<LDAP://dc=name,dc=name>"
strFilter = "(&(objectCategory=person)(sAMAccountName=" & username &
"))"
strAttributes = "sAMAccountName,AdsPath,distinguishedName"
strQuery = strBase & ";" & strFilter & ";" & strAttributes
objCommand.CommandText = strQuery
Set ADSIRecordSet = objCommand.Execute
strName = ADSIRecordSet.Fields("sAMAccountName").Value
errorNum = err.number
errorDesc = err.description
strAdsPath = ADSIRecordSet.Fields("AdsPath").Value
strDN = ADSIRecordSet.Fields("distinguishedName").Value
Set objUser = GetObject("LDAP://" & strDN)
strDisplayName = objUser.displayname
strDescription = objUser.description
err.number = "0"
Set usr = GetObject(strAdsPath)
homedir = usr.homedirectory
MsgBox homedir - This bit is OK
a=Split(homedir,"\",-1,1) - This bit is not OK.
If InStr(a, "\\") Then
newservername = len(a,3)
Else
'Do Nothing
End If
MsgBox newservername
WScript.Quit:
Please help. Thanks Tag: onmouseover and onmouseout considered acceptable in standards? Tag: 211389
Error 800A0046 with Shell.Run, but .Exec works
Hello,
I use VBScript to execute an application on a network drive.
The script looks like this:
<-----------------
const cFolder = "S:\Apps\MyProg"
const cPrg = "prg.exe"
set oShell = CreateObject("WScript.Shell")
with oShell
.CurrentDirectory = cFolder
call .Run(cFolder & "\" & cPrg)
end with
<-----------------
With some users, this script fails executing "call .Run()" with error
800A0046 - Permission denied.
If I replace "call .Run()" with "call .Exec()" using exact the same parameter,
the same user can run the script without any problems.
What is the difference between .Exec and .Run?
Why does .Run fail sometimes?
Thank you very much,
Josef Tag: onmouseover and onmouseout considered acceptable in standards? Tag: 211385
Edit a txt file
Dear All,
Pls help, I have a text file which I need to edit. The script should
search for a particular text using readline and then append a certain
text to that line.
The text file looks like
blah blah
blah blha
blah
happyb'day=gaurav
blah blah
It should look like this after modification
blah blah
blah blha
blah
happyb'day=gaurav,thanks
blah blah
P.S - The line # where "Happy'bday=gaurav" is not fixed.
Pls help, I need to get going on this and even a little insight will
be very helpful.
Thanks in advance
Gaurav Tag: onmouseover and onmouseout considered acceptable in standards? Tag: 211380
MS Office 2003 Author change
Is there a way to change the author of documents created by word, excel, etc,
so that it reflects the user that is logged in and not the organization? I
would like to create a script so this is done automatically but it seems that
UserInfo in the registry is encrypted. Is there a way around this or an
additional key that can be entered? This is to prevent students from copying
other student's work in an Office class. Tag: onmouseover and onmouseout considered acceptable in standards? Tag: 211379
Win2k3 > SP2 - Anything that can/will affect LDAP queries?
Hi,
Is there anything in SP2 for Windows Server 2003 that could affect
LDAP queries that we currently have in place that anyone knows of?
Thanks in advance. Tag: onmouseover and onmouseout considered acceptable in standards? Tag: 211377
Reading the + in Querystring
Hi All,
I have a querystring that contains the + sign as a separator, I need to read
these values individually in a select statement, for example.
&text=Single+205
where single is the type of room somebody wants and 205 is the user ID in
the Customer table.
Please help.
Regards
Simon Tag: onmouseover and onmouseout considered acceptable in standards? Tag: 211373
netobj.GetSystemInfo() in ASP/VBScript
I am looking to find the IP address, MAC address, Windows Version etc. and
ideally I want to know if some specific components are installed such as our
plugin to WM Player. Is this possible in ASP? I know it is in
.Net and in Javascript there is this function netobj.GetSystemInfo()
How would I do this in plain ASP and/or ASP with vbscript?
Thanx,
--
Anil Gupte
www.keeninc.net
www.icinema.com Tag: onmouseover and onmouseout considered acceptable in standards? Tag: 211372
Change value of "Logon script" for all users to nothing
Hi,
I'm relatively new to VBScript. I have successfully written a couple
of logon scripts for my company, with half-decent validation & program
flow. I now need to deploy this, and remove the old batch logon script
from users' account objects in AD.
Having read some posts, I've seen suggestions ranging from:
selecting multiple users in AD & selecting "Properties", then making
the change (this doesn't work on either WinXP SP2 or Win 2000)
to
using LDIFDE to export the desired information, make the change, then
re-import this data to update the schema. However, LDIFDE looks
extremely complex & bug-prone - see http://support.microsoft.com/kb/555634.
For example, this document suggests that blank values can't be used to
set attributes, which ruins my plans. It also contains lots of caveats
- by default, accounts are disabled, passwords set to NULL, "user must
change password at next logon", etc, making for a very complex series
of switches & arguements for performing any import.
Is there no way of simply using VBScript to build a collection of user
objects and loop through them, setting the desired value? Any
suggestions would be greatly appreciated.
Many thanks,
Stevie
"Normal is as normal does..." Tag: onmouseover and onmouseout considered acceptable in standards? Tag: 211371
passing a WMI collection value as a property
Hi, Please Help !
I am trying to write a script that loads some counter details from a SQL
table, executes a WMI query and then writes the results back to a SQL table.
The script will loop through the counters that it loads. My problem is I run
my WMI query
set colsettings = objWMIService.ExecQuery("SELECT PercentProcessorTime FROM
Win32_PerFormattedData_PerfOS_Processor where name = '_Total'). The actual
query contains references to the recordsets returned from SQL server
containing the counter details. For example "PercentProcessorTime" above is
replaced with objCounterRecordSet.Fields.Item("WMIProperty") and also the WMI
Class is replaced with a reference to the recordeset.
I now have one element in the reurned collection which I have to loop
through. For testing I am only trying to retrieve the value.
For each objItem in colsettings
wscript.echo objitem.PercentProcessorTime
Next.
The problem is I have several counters in my SQL table and am looping
through them so I need to replace "PercentProcessorTime" above with which
ever WMIClass parameter I happen to be working with and I cannot get this to
work. I guess what I am trying to do is use the value in a recordset as a
property for an object.
Anybody got any ideas or am i trying to do something that cannot be achieved. Tag: onmouseover and onmouseout considered acceptable in standards? Tag: 211369
Problems creating an exchange mailbox and setting permissions
Hi All,
I hope someone can help.
I am having problems accessing the Security Descriptor when creating a
New User. It errors telling me an object is required with error 424.
I have this working on other infrastructures the same as it is in this
code and therefore can not understand why it is not working.
The bit of the code which is failing is the Function to Create The
Exchange Mailbox the rest is working fine.
Here is the code
---------------------------------------------------------------------------------------------------------------------------------------------------------------------
<HTML>
<HEAD>
<TITLE>New User Creation Utility</TITLE>
<HTA:APPLICATION ID="oCreateAccount"
APPLICATIONNAME="AccountCreationScript"
BORDER="thin"
CAPTION="yes"
ICON="SETUP.ICO"
SHOWINTASKBAR="yes"
SINGLEINSTANCE="yes"
SCROLL="NO"
SYSMENU="yes"
WINDOWSTATE="normal"
MAXIMIZEBUTTON="no"
MINIMIZEBUTTON="yes">
</HEAD>
<style>
BODY
{
background-color: "#E4EAF6";
font-family: Helvetica;
font-size: 14pt;
color: "#000080";
margin-top: 5%;
margin-left: 5%;
margin-right: 5%;
margin-bottom: 5%;
}
</STYLE>
<SCRIPT LANGUAGE="VBScript">
<!--
'=================================================================================================================================================
'***When the Script window loads set the size and location of the
window.***
'=================================================================================================================================================
sub Window_Onload
self.focus()
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer &
"\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * From
Win32_DesktopMonitor")
For Each objItem in colItems
intHorizontal = objItem.ScreenWidth
intVertical = objItem.ScreenHeight
Next
intLeft = (intHorizontal - 800) / 2
intTop = (intVertical - 600) / 2
window.resizeTo 800,600
'window.moveTo intLeft, intTop
btnRunScript.disabled = false
btnReset.disabled = false
btnClose.disabled = false
end sub
'=================================================================================================================================================
'***Clear any stored Values from the entry fields.***
'=================================================================================================================================================
sub btnReset_Click
txtFirstname.value = ""
txtMiddlename.value = ""
txtLastname.value = ""
txtRefnumber.value = ""
txtRequestor.value = ""
ListAccType.value = "AccTypeStart"
btnRunScript.disabled = false
btnReset.disabled = false
btnClose.disabled = false
end sub
'=================================================================================================================================================
'***Collect information for new user entered by the Administrator.***
'=================================================================================================================================================
sub btnRunScript_click
firstname=txtFirstname.value
middlename=txtMiddlename.value
lastname=txtLastname.value
referencenumber=txtRefnumber.value
Requestor=txtRequestor.value
AccountType=ListAccType.value
'Formatting the text to make sure that the details are correct
firstname=UCASE(left(firstname,1))+LCASE(mid(firstname,2))
middlename=UCASE(left(middlename,1))+LCASE(mid(middlename,2))
If mid(lastname,2) = "'" Then
lastname=UCASE(left(lastname,3))+LCASE(mid(lastname,4))
Else
lastname=UCASE(left(lastname,1))+LCASE(mid(lastname,2))
End If
btnRunScript.disabled = true
btnReset.disabled = true
btnClose.disabled = true
if firstname="" then
msgbox "Please enter the users First Name"
btnRunScript.disabled = false
btnReset.disabled = false
btnClose.disabled = false
exit sub
elseif lastname = "" then
msgbox "Please enter the users Surname"
btnRunScript.disabled = false
btnReset.disabled = false
btnClose.disabled = false
exit sub
elseif referencenumber = "" then
msgbox "Please enter the Reference Number"
btnRunScript.disabled = false
btnReset.disabled = false
btnClose.disabled = false
exit sub
elseif Requestor = "" then
msgbox "Please enter the Requestor's Name"
btnRunScript.disabled = false
btnReset.disabled = false
btnClose.disabled = false
exit sub
elseif AccountType = "AccTypeStart" then
msgbox "Please select the Account Type"
btnRunScript.disabled = false
btnReset.disabled = false
btnClose.disabled = false
exit sub
else
'do nothing
end if
call
createAccount(firstname,middlename,lastname,referencenumber,Requestor,AccountType)
end sub
'=================================================================================================================================================
'***Collect information for new user entered by the Administrator,
then create the account.***
'=================================================================================================================================================
sub
createAccount(firstname,middlename,lastname,referencenumber,Requestor,AccountType)
'On error resume next
intAccValue = 544
inputdomain="Domain"
inputou="OU"
Set wshshell = CreateObject("wscript.shell")
username = wshshell.expandenvironmentstrings("%username%")
strDomain="Domain.Com"
CurrDateTime=now
firstinitial = UCASE(left(firstname,1))
strFile = "filepath"
strExServer = "Servername"
strProfPath = "\\Servername\User$\P"
strHomeDir = "\\Servername\User$\H"
strTempPath = strHomeDir & firstinitial & "\_Template\"
msgbox "Please verify the following details of the account to create"
& VBCRLF & "Firstname: " & firstname & VBCR & "Middlename: " &
middlename & VBCR & "Lastname: " & lastname & VBCR & "Reference
Number: " & referencenumber
MsgboxResult=msgbox("Is this information correct?",
259,"Confirmation")
if MsgboxResult = 7 then
txtFirstname.value = ""
txtMiddlename.value = ""
txtLastname.value = ""
txtRefnumber.value = ""
ListAccType.value = "AccTypeStart"
btnRunScript.disabled = false
btnReset.disabled = false
btnClose.disabled = false
exit sub
elseif MsgboxResult = 2 then
window_close
exit sub
else
'do nothing
end if
'Connect to the usersdatabase to get sitedetails and record the
transaction
set conn=createobject("adodb.connection")
conn.connectiontimeout = 30000
conn.commandtimeout=30000
set myset=createobject("adodb.recordset")
conn.open "Driver={Microsoft Access Driver
(*.mdb)};Dbq=UserAdmin.mdb;"
sql="select * from Exchange where exchangeserver='" & strExServer &
"'"
'Msgbox sql
set myset=conn.execute(sql)
exchangeserver=myset("exchangeServer")
storagegroup1=myset("storagegroup1")
storagegroup2=myset("storagegroup2")
informationstore1=myset("informationstore1")
informationstore2=myset("informationstore2")
informationstore3=myset("informationstore3")
informationstore4=myset("informationstore4")
informationstore5=myset("informationstore5")
informationstore6=myset("informationstore6")
informationstore7=myset("informationstore7")
informationstore8=myset("informationstore8")
informationstore9=myset("informationstore9")
'Create a temporary account name
testusername=UCASE(left(firstname,1) & left(middlename,1) &
left(lastname,1)) & LCASE(mid(lastname,2))
'Check if there is an account with this name already
nameok=testaccount(testusername)
if nameok=0 then
' The account name is already in use, need to alter the name used
msgbox "This Account name is already in use, there is a duplicate
entry." & VBCRLF & "Please verify the details entered, you will need
to start again once the details have been verified."
txtFirstname.value = ""
txtMiddlename.value = ""
txtLastname.value = ""
txtRefnumber.value = ""
txtRequestor.value = ""
ListAccType.value = "AccTypeStart"
btnRunScript.disabled = false
btnReset.disabled = false
btnClose.disabled = false
exit sub
else
' This name is free so use it
end if
'Now we create the base user account so that we can assign properties
to it
objectname="LDAP://ou=users,ou=" & inputou & ",dc=" & inputdomain &
",dc=COM"
'Now we create the new user account so that we can set its properties
Set ou = GetObject(objectname)
'Have to remember to escape the , by preceeding it with a \, so
smith, john becomes smith\, john this still shows as smith, john in
the gui though.
If middlename = "" Then
fullname="cn=" & firstname & " " & lastname
Else
fullname="cn=" & firstname & " " & middlename & " " & lastname
End If
Set usr = ou.Create("user", fullname)
usr.Put "samAccountName", testusername
usr.SetInfo
usr.lastname = lastname
usr.givenname = firstname
if len(middlename)>0 then
usr.initials=left(middlename,1)
end if
usr.setinfo
usr.userPrincipalName=testusername & "@" & inputdomain & ".co.uk"
If middlename = "" Then
usr.displayname=firstname & " " & lastname
Else
usr.displayname=firstname & " " & middlename & " " & lastname
End If
usr.description=AccountType
usr.setinfo
usr.profilepath=strProfPath & firstinitial & "\" & testusername
usr.homedrive="P:"
usr.homedirectory=strHomeDir & firstinitial & "\" & testusername
usr.SetInfo
usr.info="Created via script by " & username & " on " & now & " Ref:
" & referencenumber & VBTAB & "Requested by: " & Requestor
usr.SetInfo
usr.Put "userAccountControl", intAccValue
usr.setinfo
homedir = usr.homedirectory
profiledir = usr.profilepath
'Now we need to create the homedrive and profilepath for the account
set fso=createobject("scripting.filesystemobject")
if fso.folderexists(usr.homedirectory) then
msgbox "There is already a home directory for this user. Please
verify it is correct and with the correct permissions"
else
set f=fso.createfolder(usr.homedirectory)
end if
if fso.folderexists(usr.profilepath) then
msgbox "There is already a profile directory for this user. Please
verify it is correct and with the correct permissions"
else
set f=fso.createfolder(usr.profilepath)
end if
'And set the permissions
cmdline="cmd /c setacl.exe -on " & homedir & " -ot file -actn ace -
ace " & "n:" & inputdomain & "\" & testusername &
";p:full;s:n;i:sc,so;m:grant;w:dacl"
cmdline1="cmd /c setacl.exe -on " & profiledir & " -ot file -actn
ace -ace " & "n:" & inputdomain & "\" & testusername &
";p:full;s:n;i:sc,so;m:grant;w:dacl"
Set WshShell = CreateObject("WScript.Shell")
poi=wshshell.run(cmdline)
poi1=wshshell.run(cmdline1)
'Copy the _Template folder and it's contents to the Users Home Folder
fso.CopyFolder strTempPath & "*.*", homedir, True
'Now we enable the account
res=addgroups(inputdomain,testusername,AccountType)
strDate = now
'get numeric value for day of the week
myDayName = WeekDay(strDate)
'convert numeric value to day name
myDayName = WeekDayName(myDayName)
DayofWeek = LCASE(myDayName)
CurrentDay = Dayofweek
usr.Accountdisabled=0
strPassword=CurrentDay
usr.setpassword strPassword
usr.put "pwdLastSet", 0
usr.setinfo
'Now we create the mailbox
'***First convert the first character of the firstname into an ascii
code***
'***In order to sort the user into the correct Information
Store ***
FirstChar= "H"
FirstCharAsci=Asc(FirstChar)
AsciA=Asc("A")
AsciB=Asc("B")
AsciC=Asc("C")
AsciD=Asc("D")
AsciE=Asc("E")
AsciF=Asc("F")
AsciG=Asc("G")
AsciH=Asc("H")
AsciI=Asc("I")
AsciJ=Asc("J")
AsciK=Asc("K")
AsciL=Asc("L")
AsciM=Asc("M")
AsciN=Asc("N")
AsciO=Asc("o")
AsciP=Asc("P")
AsciQ=Asc("Q")
AsciR=Asc("R")
AsciS=Asc("S")
AsciT=Asc("T")
AsciU=Asc("U")
AsciV=Asc("V")
AsciW=Asc("W")
AsciX=Asc("X")
AsciY=Asc("Y")
AsciZ=Asc("Z")
Call RUS
strAlias=UCASE(Left(firstname,1) & left(middlename,1) & left(lastname,
1)) & LCASE(Left(lastname,2))
smtpok = testsmtp(firstname,middlename,lastname,inputdomain,strAlias)
If smtpok = 0 Then
strAlias=UCASE(Left(firstname,1) & left(middlename,1) &
left(lastname,1)) & LCASE(lastname,2) & "X"
smtpok =
testsmtp(firstname,middlename,lastname,inputdomain,strAlias)
If smtpok = 0 Then
strAlias=UCASE(Left(firstname,1) & left(middlename,1) &
left(lastname,1)) & LCASE(lastname,2) & "XX"
smtpok =
testsmtp(firstname,middlename,lastname,inputdomain,strAlias)
If smtpok = 0 Then
strAlias=UCASE(Left(firstname,1) & left(middlename,1) &
left(lastname,1)) & LCASE(lastname,2) & "XXX"
smtpok =
testsmtp(firstname,middlename,lastname,inputdomain,strAlias)
If smtpok = 0 Then
strAlias=UCASE(Left(firstname,1) & left(middlename,1) &
left(lastname,1)) & LCASE(lastname,2) & "XXXX"
Else
'Do Nothing
End If
Else
'Do Nothing
End If
Else
'Do Nothing
End If
Else
'Do Nothing
End If
'Call ChangeSmtpAddress(strAlias,fullname,site,inputdomain,inputou)
If FirstCharAsci >= AsciA AND FirstCharAsci <= AsciB then
storagegroup=storagegroup1
informationstore=informationstore1
ElseIf FirstCharAsci >= AsciC AND FirstCharAsci <= AsciD then
storagegroup=storagegroup1
informationstore=informationstore2
ElseIf FirstCharAsci >= AsciE AND FirstCharAsci <= AsciH then
storagegroup=storagegroup1
informationstore=informationstore3
ElseIf FirstCharAsci >= AsciI AND FirstCharAsci <= AsciK then
storagegroup=storagegroup1
informationstore=informationstore4
ElseIf FirstCharAsci >= AsciL AND FirstCharAsci <= AsciM then
storagegroup=storagegroup2
informationstore=informationstore5
ElseIf FirstCharAsci >= AsciN AND FirstCharAsci <= AsciP then
storagegroup=storagegroup2
informationstore=informationstore6
ElseIf FirstCharAsci >= AsciQ AND FirstCharAsci <= AsciS then
storagegroup=storagegroup2
informationstore=informationstore7
ElseIf FirstCharAsci >= AsciT AND FirstCharAsci <= AsciZ then
storagegroup=storagegroup2
informationstore=informationstore9
Else
storagegroup=storagegroup2
informationstore=informationstore8
End if
'***Build the LDAP url in order to create the mailbox'***
strLDAPUrl="LDAP://CN=" & informationstore & ",CN=" & storagegroup &
",CN=InformationStore,CN=" & _
exchangeserver & ",CN=Servers,CN=Admin Group,CN=Administrative
Groups,CN=" & inputdomain & _
",CN=Microsoft
Exchange,CN=Services,CN=Configuration,dc=Domain,dc=COM"
bContinue=CreateNewUserMailbox(usr, strLDAPUrl, inputdomain,
testusername)
If bContinue=True then
bContinue2=CreateMailboxFolders(exchangeserver, strAlias,
strPassword)
Else
msgbox "Failed to create Mailbox for this user, please create it
manually"
End If
'write out DB information
set dbupdaters=createobject("adodb.recordset")
dbupdaters.open "Users",conn,2,2,2
dbupdaters.addnew
dbupdaters("firstname")=firstname
dbupdaters("middlename")=middlename
dbupdaters("lastname")=lastname
dbupdaters("accounttype")=AccountType
dbupdaters("homeserver")=homedir
dbupdaters("storagegroup")=storagegroup
dbupdaters("informationstore")=informationstore
dbupdaters("UserID")=testusername
dbupdaters("creator")=username
dbupdaters("Domain")=inputdomain
dbupdaters("Creation Time")=now
dbupdaters.update
txtFirstname.value = ""
txtMiddlename.value = ""
txtLastname.value = ""
txtRefnumber.value = ""
txtRequestor.value = ""
ListAccType.value = "AccTypeStart"
msgbox "Account has been created successfully."
MsgBox "Account Username is: " & testusername & VBCRLF & "Account
Password is: " & strPassword & VBCRLF & "Home Server: " & _
homedir & VBCRLF & "Profile Directory: " & profiledir
set dbupdaters=nothing
set conn=nothing
Set strPassword=nothing
btnRunScript.disabled = false
btnReset.disabled = false
btnClose.disabled = false
end sub
'=================================================================================================================================================
'***Sub and Function to Initiate the Recipient Update Service and
force replication.***
'=================================================================================================================================================
Sub RUS
'This sample finds the first Exchange Organization and
'starts the server RUS. If you have multiple Exchange
'organizations you will want to modify the code.
'This sample does a serverless bind finding the first DC
'to respond. You may want to modify the code to specify
'a specific server in the Bind statement.
Dim RootDse
Set RootDse = GetObject("LDAP://RootDSE")
strdn = RootDse.Get("defaultNamingContext")
Set oConfig = GetObject("LDAP://" & strdn)
strDomainName = oConfig.Get("name")
strConfigurationNC = RootDse.Get("ConfigurationNamingContext")
strExchangeOrg = FindAnyOrg(strConfigurationNC)
strRUS = "CN=Recipient Update Service (" & strDomainName &
"),CN=Recipient Update Services," & "CN=Address Lists Container,CN=" &
strExchangeOrg & ",CN=Microsoft Exchange,CN=Services," &
"CN=Configuration," & strdn
Set objRUS = GetObject("LDAP://" & strRUS)
objRUS.Put "msExchReplicateNow", True
objRUS.SetInfo
End Sub
Function FindAnyOrg(strConfigurationNC)
Set oConnection = CreateObject("ADODB.Connection")
Set oCommand = CreateObject("ADODB.Command")
Set oRecordSet = CreateObject("ADODB.RecordSet")
Dim strQuery
'Open the Connection
oConnection.Provider = "ADsDSOObject"
oConnection.Open "ADs Provider"
'Build the query to find the private Exchange Organization
strQuery = "<LDAP://" & strConfigurationNC & ">;
(objectCategory=msExchOrganizationContainer);name,adspath;subtree"
oCommand.ActiveConnection = oConnection
oCommand.CommandText = strQuery
Set oRecordSet = oCommand.Execute
'If we have an Organization then return the first one
If Not oRecordSet.EOF Then
oRecordSet.MoveFirst
FindAnyOrg = CStr(oRecordSet.Fields("name").Value)
Else
FindAnyOrg = ""
End If
'Clean Up
oRecordSet.Close
oConnection.Close
Set oRecordSet = Nothing
Set oCommand = Nothing
Set oConnection = Nothing
End Function
'=================================================================================================================================================
'***Sub to change the smtp address.***
'=================================================================================================================================================
Sub ChangeSmtpAddress(strAlias,fullname,site,inputdomain,inputou)
Set objUser = GetObject("LDAP://" & fullname & ",OU=users,ou=" &
inputou & ",dc=" & inputdomain & ",dc=Local")
vProxyAddresses = objUser.proxyaddresses
sAddress = "SMTP:" & strAlias & "@" & inputdomain & ".co.uk"
nProxyAddresses = uBound(vProxyAddresses)
Do While (nProxyAddresses <> 2) or (IsNull(nProxyAddresses))
nProxyAddresses = uBound(vProxyAddresses)
vProxyAddresses = objUser.proxyaddresses
Loop
i = 0
Do While i <= nProxyAddresses
email = vProxyAddresses(i)
If Left (email,5) = "SMTP:" Then
ReDim Preserve vProxyAddresses(nProxyAddresses)
vProxyAddresses(nProxyAddresses) = sAddress
objUser.proxyaddresses = vProxyAddresses
objUser.SetInfo
End If
i = i + 1
Loop
objUser.Put "mail", strAlias & "@" & inputdomain & ".co.uk"
objUser.SetInfo
End Sub
'=================================================================================================================================================
'***Check SMTP Alias across the domain.***
'=================================================================================================================================================
function testsmtp(firstname,middlename,lastname,inputdomain,strAlias)
on error resume next
Set objCommand = CreateObject("ADODB.Command")
Set objConnection = CreateObject("ADODB.Connection")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
objCommand.ActiveConnection = objConnection
strBase = "<LDAP://ou=" & inputou & ",dc=" & inputdomain & ",dc=COM>"
strFilter = "(&(objectCategory=person)(proxyaddresses=SMTP:" &
strAlias & "@" & inputdomain & ".co.uk"))"
strAttributes = "proxyaddresses,AdsPath"
strQuery = strBase & ";" & strFilter & ";" & strAttributes
objCommand.CommandText = strQuery
Set ADSIRecordSet = objCommand.Execute
strProxy = ADSIRecordSet.Fields("proxyaddresses").Value
errorNum = err.number
errorDesc = err.description
if err.number = 0 then
testsmtp = 0
else
testsmtp = 1
end if
end function
'=================================================================================================================================================
'***Check User name across the domain.***
'=================================================================================================================================================
function testaccount(testusername)
on error resume next
'Check via the WinNT provider as we want the accounts to be unique
across the domain not the OU
set checkuser=getobject("WinNT://" & inputdomain & "/" & testusername
& ",User")
testaccount=err.number
end function
'=================================================================================================================================================
'***Add the user to the groups.***
'=================================================================================================================================================
function addgroups(inputdomain,testusername,AccountType)
On Error Resume Next
strGroup1 = "Group1"
strGroup2 = "Group2"
strGroup3 = "Group3"
strPermGroup = "Group4"
Set User = GetObject("WinNT://" & inputdomain & "/" & testusername &
",user")
Set Group = GetObject("WinNT://" & inputdomain & "/" & strGroup1 &
",group")
If Group.IsMember(User.AdsPath) = TRUE Then
'Do Nothing
Else
strMember = Group.Add(User.AdsPath)
End If
Set Group = GetObject("WinNT://" & inputdomain & "/" & strGroup2 &
",group")
If Group.IsMember(User.AdsPath) = TRUE Then
'Do Nothing
Else
strMember = Group.Add(User.AdsPath)
End If
Set Group = GetObject("WinNT://" & inputdomain & "/" & strGroup3 &
",group")
If Group.IsMember(User.AdsPath) = TRUE Then
'Do Nothing
Else
strMember = Group.Add(User.AdsPath)
End If
If AccountType = "Standard User Account" Then
Set Group = GetObject("WinNT://" & inputdomain & "/" & strPermGroup
& ",group")
If Group.IsMember(User.AdsPath) = TRUE Then
'Do Nothing
Else
strMember = Group.Add(User.AdsPath)
End If
Else
'Do Nothing
End If
end function
'=================================================================================================================================================
'***Create the new users exchange mailbox.***
'=================================================================================================================================================
Function CreateNewUserMailbox(usr, strLDAPUrl, inputdomain,
testusername)
usr.createmailbox strLDAPUrl
usr.setinfo
'Set the Delivery Size Limit for the User to 6Mb
usr.put "submissionContLength", "6144"
usr.SetInfo
Call RUS
sTrusteeName=inputdomain & "\" & testusername
'Get the copy Mailbox Security Descriptor (SD) stored on the
msExchMailboxSecurityDescriptor attribute
usr.GetInfoEx Array("msExchMailboxSecurityDescriptor"), 0
Set oSecurityDescriptor = usr.Get("msExchMailboxSecurityDescriptor")
'Extract the Discretionary Access Control List (ACL) using the
IADsSecurityDescriptor interface
Set dacl = oSecurityDescriptor.DiscretionaryAcl
MsgBox err.number & VBTAB & err.description
AddAce dacl, sTrusteeName, 131073, 0, 2, 0, 0, 0
'Add the modified DACL back onto the Security Descriptor
oSecurityDescriptor.DiscretionaryAcl = dacl
'Save New SD onto the user
usr.Put "msExchMailboxSecurityDescriptor", oSecurityDescriptor
'Commit changes from the property cache to the information store
usr.SetInfo
'MsgBox "Done viewing and modifying the copy of the Mailbox Security
Descriptor"
CreateNewUserMailbox = True
End Function
'=================================================================================================================================================
'***Create the mailbox folders.***
'=================================================================================================================================================
Function CreateMailboxFolders(exchangeserver, strAlias, strPassword)
CreateMailboxFolders = False
'Build the URL to the user's mailbox.
strMailboxURL = "http://" & exchangeserver & "/Exchange/" & strAlias
& "/"
'Build the Domain\Username string.
strUserDomain = inputdomain + "\" + testusername
'Create the XMLHTTP object.
Set oXMLHTTP = CreateObject("microsoft.xmlhttp")
'Open the request object with the GET method. Specify the source
URI,
'that it will run asynchronously, and the username/password of the
'new user.
oXMLHTTP.Open "GET", strMailboxURL, False, strUserDomain, strPassword
'Set the language in which the mailbox folders will be created.
oXMLHTTP.setRequestHeader "Accept-Language", "en-us"
oXMLHTTP.setRequestHeader "Connection", "Keep-Alive"
'Send the GET method request. If the mailbox folders
'have not yet been created, this method will have the side
'effect of forcing the Exchange server to create them in
'the language specified in the "Accept-Language" header.
oXMLHTTP.Send ("")
If (oXMLHTTP.Status >= 200) And (oXMLHTTP.Status < 300) Then
msgbox "Mailbox folders for " & strAlias & " successfully created."
CreateMailboxFolders = True
Else
'GET method did not successfully force creation of mailbox folders.
CreateMailboxFolders = False
End If
Set oXMLHTTP = Nothing
End Function
'==========================================================================================