Here is the script we use for provisioning our customers initial email
account upon signup. It only works with IIS 4.0 required DLL's are listed.
<% @ language = "VBScript" %>
<%
Option Explicit
on error resume next
debuglvl = 1
'===============================================================
'Required Object DLL's
'ISPSignup ServerName DLLS from IIS Resource Kit, ISPSetup Object
'Must be installed and working properly
'Registry Access Component From IIS Resource KIT
'Must be installed and functioning properly
'
'You may use this script and may modify it. Please retain all
'documentation, and copy right info.
'Author:Jim Barber
'Company: Hexagon Net
'Copy Right 1998
'===============================================================
'===============================================================
' Create all variables using the option explicit statement
' a loose variable here could do some wicked and unpredictable
' things while creating the new keys for the ServerNames
' Special thanks to Andy Paluch for the encryption algorithm
' for the passwords.
'
'Instructions:
'Create a form which posts to this file
'the form must pass "adminuser","password","hostname"
' I.E. user1,password,mail.somedomain.com
'
'Replace the server path and ServerName name and it should work fine.
'===============================================================
Dim MyKey 'This variable holds the value of the Registry Key we are working
with
Dim debuglvl 'This variable alows us to see debuging messages of varing
levels
Dim KeyExitsts 'This will be a boolean variable that will allow us to
transverse the registry and look for the next free ServerName number
Dim oIMVS 'We will set this to an object and use it to access various system
functions as the administrator of the system
Dim vNum 'This variable will hold the virtual ServerName number for use when
we create the registry keys
Dim Reg 'This will be set to the registry access object contained in the IIS
Resource kit.
Dim NewVSKey 'New Virtual ServerName Key for the registry.
Dim strVU 'The admin user filled from the previous form using the request
method
Dim strVP 'The password for the admin user filled from the previous form
using the request method
Dim strULen 'The length of the user name
Dim strPLen 'The length of the password
Dim rlUStr 'Alternate User Name String for encryption
Dim cvuChar 'Holds the converted asc character value for the current
character in the user name string
Dim cvpChar 'Holds the converted asc character value for the current
character in the password string.
Dim tvChar 'Holds the combined asc character values for converted
characters from password and user name strings.
Dim eStr 'This is the encrypted password
Dim encrypt 'variable for the for do loop for encryption
Dim rlConv 'variable for the for do loop if the user name is shorter than
the password
Dim Pos1 'variable for the mid function for getting a specific character
within the string.
Dim hostname ' Host name of the new virutal server
Dim bContinue 'Variable to use for function
Dim KeyExists 'variable to use for function
'=========================================================================
'Encrypt the password for the registry
'=========================================================================
hostname = Request.Form("hostname")
strVU = Request.Form("username")
rlUStr = strVU
strVP = Request.Form("Password")
strULen = Len(strVU)
strPLen = Len(strVP)
if debuglvl > 0 then
Response.Write strULen & "<br>"
Response.Write strPLen & "<br>"
end if
Pos1 = 1
If strULen < strPLen then
For rlConv = strULen to strPLen - 1
rlUStr = rlUStr & Mid(strVU,Pos1,1)
if debuglvl > 0 then
Response.Write "Convert User Length " & rlUStr & " Position " & rlConv
& "<br>"
end if
Pos1 = Pos1 + 1
if Pos1 > strULen then
Pos1 = 1
end if
Next
end if
For encrypt = 1 to Len(rlUStr)
cvuChar = Asc(CStr(Mid(rlUStr,encrypt,1)))
cvpChar = Asc(CStr(Mid(strVP,encrypt,1)))
tvChar = cvuChar + cvpChar
eStr = eStr & Hex(tvChar)
If debuglvl > 0 then
Response.Write eStr & "<br>"
end if
Next
if debuglvl > 0 then
Response.Write "<strong>" & eStr & "</strong><br>"
end if
'==================================================================
'The following object is available within the IIS Resource Kit or from the
isp resource site.
'This is so the objects following this have the proper permissions for
operations
'==================================================================
Set oIMVS = Server.CreateObject("IspSignup.IspSetup")
bContinue = oIMVS.LogonUserAs ("DomainName", "Administrator", "Password")
'===================================================================
'We now create the directories for the mail and for any following users.
'Replace with your ServerName like this \\Mars\c$\imail so the completed
string may look something like this
' \\Mars\c$\imail\domain.com or \\Venus\ShareName\imail\mail.domain.com
'====================================================================
oIMVS.AspExtCreateRemoteDir CStr("\\ServerName\ShareName\imail\" & hostname)
'i.e. domain.com name or mail.domain.com
oIMVS.AspExtCreateRemoteDir CStr("\\ServerName\ShareName\imail\" & hostname
& "\" & strVU)
'====================================================================
'Create the Registry object to access the registry of the ServerName.
'We will flush each access immediatly to reduce the risk of data loss and
creation of keys.
'====================================================================
Set Reg = Server.CreateObject("IISSample.RegistryAccess")
'====================================================================
'Start looking for a empty virtual ServerName starting at 300
'Set the inital value of KeyExists to True since we know that # 301 exists
'Transverse the registry keys and find the next empty virtual ServerName.
'====================================================================
vNum = 300
KeyExists = True
While (KeyExists) 'which is true until an empty ServerName number is found
vNum = vNum + 1
MyKey =
"\\ServerName\HKEY_LOCAL_MACHINE\SOFTWARE\Ipswitch\IMail\Domains\$virtual" &
vNum & ""
KeyExists = Reg.KeyExists(MyKey)
if debuglvl > 0 then
Response.Write MyKey & "<br>"
Response.Write KeyExists & "<br>"
end if
Wend
'===========================================================================
=====
'Write the next virtual ServerName number to the screen if debuglvl is
greater than 0
'===========================================================================
======
if debuglvl > 0 then
Response.Write "The next free Virtual Server number is: " & vNum
end if
'===========================================================================
=========
' set a string value but do not force the registry to flush the write
' create a virtual server named test.com or something like this.
' I have a dummy domain setup at virutal300 for copy purposes
' we get the domain name from the previous form usging the request object
native to asp
'===========================================================================
==========
Reg.CopyKey
"\\ServerName\HKEY_LOCAL_MACHINE\SOFTWARE\Ipswitch\IMail\Domains\$virtual300
",MyKey, True
Reg.Set MyKey & "\Official",hostname,TRUE
NewVSKey =
"\\ServerName\HKEY_LOCAL_MACHINE\SOFTWARE\Ipswitch\IMail\Domains\" &
hostname
Reg.CopyKey
"\\ServerName\HKEY_LOCAL_MACHINE\SOFTWARE\Ipswitch\IMail\Domains\test.com",N
ewVSKey, True
Reg.DeleteKey NewVSKey & "\Users\default"
Reg.CopyKey
"\\ServerName\HKEY_LOCAL_MACHINE\SOFTWARE\Ipswitch\IMail\Domains\test.com\Us
ers\default",NewVSKey & "\Users\" & strVU,TRUE
Reg.Set NewVSKey & "\Address","$virtual" & vNum,TRUE
Reg.Set NewVSKey & "\TopDir","D:\IMAIL\" & hostname,TRUE
Reg.Set NewVSKey & "\Users\root\MailAddr","root@" & hostname,TRUE
Reg.Set NewVSKey & "\Users\" & strVU & "\MailAddr",strVU & "@" &
hostname,TRUE
Reg.Set NewVSKey & "\Users\" & strVU & "\Password", eStr,TRUE
Reg.Set NewVSKey & "\Users\" & strVU & "\FullName", "",TRUE
Reg.Set NewVSKey & "\Users\" & strVU & "\info\cn", "",TRUE
Reg.Set NewVSKey & "\Users\" & strVU & "\info\GivenName", "",TRUE
Reg.Set NewVSKey & "\Users\" & strVU & "\info\Mail", strVU & "@" &
hostname,TRUE
Response.Redirect "your next page"
%>
----- Original Message -----
From: talon <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, January 04, 2000 8:08 AM
Subject: [IMail Forum] Registry
> Anyone have an app for adding registry keys remotely ? im trying to make
it so i can add imail users from another pc on my lan.
>
> - Tim
> Please visit http://www.ipswitch.com/support/mailing-lists.html
> to be removed from this list.
>
Please visit http://www.ipswitch.com/support/mailing-lists.html
to be removed from this list.