stevebanks
Programmer
- Mar 30, 2004
- 93
Hi everyone,
I have a project that i am doing and it is a fair bit of code to create a virtual server, website, NT username, Mailserver username, disk quota, etc.. The code i am using is a bit of everyone elses, although I have modified it to my own needs. My problem is, that the script will create everything, the virtual server, website, NT username, mailserver info, disk quota, etc... but will then LOOPS back to the beginning and starts again which causes a File already exists error... There are NO loops (as far as I can see) in the code.??? I am most confused!!!
Here is the code:
Any help would be most appreciated!!!
Thanks
I have a project that i am doing and it is a fair bit of code to create a virtual server, website, NT username, Mailserver username, disk quota, etc.. The code i am using is a bit of everyone elses, although I have modified it to my own needs. My problem is, that the script will create everything, the virtual server, website, NT username, mailserver info, disk quota, etc... but will then LOOPS back to the beginning and starts again which causes a File already exists error... There are NO loops (as far as I can see) in the code.??? I am most confused!!!
Here is the code:
Code:
<%
conn = "dsn=xxxxx;"
Dim domain
domain = Request("M_domain")
Dim add
Dim add_numRows
Set add = Server.CreateObject("ADODB.Recordset")
add.ActiveConnection = conn
add.Source = "SELECT * FROM users"
add.CursorType = 0
add.CursorLocation = 2
add.LockType = 2
add.Open()
add_numRows = 0
add.addnew
add("yourdomain") = Request("M_domain")
add("password") = Request("M_password")
add("mailboxes") = Request("M_nopop3")
add("mysqldbs") = Request("M_mysql")
add("email") = "admin@" & Request("M_domain")
add("foldersize") = Request("M_amwebspace")
add("telephone") = Request("M_telephone")
add("name") = Request("M_name")
add("address") = Request("M_address")
add("otheremail") = Request("M_otheremail")
add("transfer") = Request("M_amtransfer")
add.update
'Create Directory for storing info in...
unamefolder = "d:inetpub\[URL unfurl="true"]wwwroot\"[/URL] & domain
web = "d:\inetpub\[URL unfurl="true"]wwwroot\"[/URL] & domain & "\web"
userdb = "d:\inetpub\[URL unfurl="true"]wwwroot\"[/URL] & domain & "\db"
set dirobj = CreateObject("Scripting.FileSystemObject")
dirobj.CreateFolder(unamefolder)
dirobj.CreateFolder(web)
dirobj.CreateFolder(userdb)
'Use ASP Execute as the helper for ACL
Set Executor = Server.CreateObject("ASPExec.Execute")
Executor.Application = "c:\windows\system32\cacls"
' Set the ACL for user directory
Executor.Parameters = userdir & " /t /e /p " & domain & ":f"
strResult = Executor.ExecuteDosApp
' Set the ACL for DB directory
Executor.Parameters = userdb & " /t /e /g IUSR_xxxxx-xxxxxx:c "
strResult = Executor.ExecuteDosApp
' Set the ACL for the CGI directory
set Executor = nothing
'Create NT username
Dim Container
Dim NewUser
Dim CurrentDate
Dim ExpireDate
Dim HomeDir
HomeDir = "d:\Inetpub\[URL unfurl="true"]wwwroot\"[/URL] & domain
CurrentDate = DateSerial(Year(Now),Month(Now),Day(Now))
ExpireDate = DateAdd("d",400000,CurrentDate)
Set Container = GetObject("WinNT://xxxxxx-xxxxxxx")
Set NewUser = Container.Create("user", domain)
NewUser.FullName = Full_Name
NewUser.Description = Request("M_email")
NewUser.AccountExpirationDate = ExpireDate
NewUser.HomeDirectory = HomeDir
NewUser.SetInfo
NewUser.SetPassword(Request("M_password"))
Set objIIS = GetObject("IIS://xxxxx-xxxxxxx/W3SVC/xxxxxxxx/ROOT")
strVirtualDirectoryPath = "d:\Inetpub\[URL unfurl="true"]wwwroot\"[/URL] & domain
Set objVirtualDirectory = objIIS.Create("IISWebVirtualDir", domain)
objVirtualDirectory.AccessScript = blnScriptPermissions
objVirtualDirectory.Path = strVirtualDirectoryPath
objVirtualDirectory.AppCreate blnInProcessApplication
objVirtualDirectory.AccessWrite = blnWritePermissions
objVirtualDirectory.AccessRead = blnReadPermissions
objVirtualDirectory.AccessExecute = blnExecutePermissions
objVirtualDirectory.AuthAnonymous =True
objVirtualDirectory.AnonymousUserName=strOwner
objVirtualDirectory.AnonymousPasswordSync=True
objVirtualDirectory.AppCreate (True)
objVirtualDirectory.SetInfo
'CREATE DOMAIN.COM website in IIS
Dim oWeb,oSite,oRoot,nSiteID
Const POOLED = 2
Set oWeb = GetObject("IIS://LocalHost/W3SVC")
' Find next ID for new server and stop current servers
nSiteID = 0
For Each oSite In oWeb
If oSite.Class="IIsWebServer" Then
If IsNumeric(oSite.Name) Then
If CLng(oSite.Name)>nSiteID Then _
nSiteID = CLng(oSite.Name)
End If
End If
Next
nSiteID = nSiteID + 1
' Create new server
Set oSite = oWeb.Create("IIsWebServer",CStr(nSiteID))
oSite.ServerComment = domain
oSite.DefaultDoc = "default.htm,default.asp,index.asp,index.htm,index.php"
oSite.ServerBindings = "12.345.678.90:80:[URL unfurl="true"]www."&[/URL] domain
oSite.ServerAutoStart = 1
oSite.SetInfo
' Create root
Set oRoot = oSite.Create("IIsWebVirtualDir","ROOT")
oRoot.Path = "d:\inetpub\[URL unfurl="true"]wwwroot\"[/URL] & domain & "\web\"
oRoot.AccessRead = True
oRoot.SetInfo
oSite.Start
'CREATE MAIL.DOMAIN.COM website in IIS
Dim nWeb,nSite,nRoot,mSiteID
Set nWeb = GetObject("IIS://LocalHost/W3SVC")
' Find next ID for new server and stop current servers
mSiteID = 0
For Each nSite In nWeb
If nSite.Class="IIsWebServer" Then
If IsNumeric(nSite.Name) Then
If CLng(nSite.Name)>mSiteID Then _
mSiteID = CLng(nSite.Name)
End If
End If
Next
mSiteID = mSiteID + 1
' Create new server
Set nSite = nWeb.Create("IIsWebServer",CStr(mSiteID))
nSite.ServerComment = "mail." & domain
nSite.DefaultDoc = "index.php"
nSite.ServerBindings = "12.345.678.90:80:mail."& domain
nSite.ServerAutoStart = 1
nSite.SetInfo
' Create root
Set nRoot = nSite.Create("IIsWebVirtualDir","ROOT")
nRoot.Path = "d:\inetpub\[URL unfurl="true"]wwwroot\mail.xxxxxx.co.uk\SquirrelMail[/URL] For hMailServer mod 0.1\"
nRoot.AccessRead = True
nRoot.SetInfo
nSite.Start
'CREATE ADMIN.DOMAIN.COM website in IIS
Dim xWeb,xSite,xRoot,xSiteID
Set xWeb = GetObject("IIS://LocalHost/W3SVC")
' Find next ID for new server and stop current servers
xSiteID = 0
For Each xSite In xWeb
If xSite.Class="IIsWebServer" Then
If IsNumeric(xSite.Name) Then
If CLng(xSite.Name)>xSiteID Then _
xSiteID = CLng(xSite.Name)
End If
End If
Next
xSiteID = xSiteID + 1
' Create new server
Set xSite = xWeb.Create("IIsWebServer",CStr(xSiteID))
xSite.ServerComment = "admin." & domain
xSite.DefaultDoc = "index.asp"
xSite.ServerBindings = "12.345.678.90:80:admin."& domain
xSite.ServerAutoStart = 1
xSite.SetInfo
' Create root
Set xRoot = xSite.Create("IIsWebVirtualDir","ROOT")
xRoot.Path = "d:\inetpub\[URL unfurl="true"]wwwroot\admin.xxxxxx.co.uk\"[/URL]
xRoot.AccessRead = True
xRoot.SetInfo
xSite.Start
'Restrict disk quota for user
Set colDiskQuotas = CreateObject("Microsoft.DiskQuota.1")
colDiskQuotas.Initialize "D:\", True
set objUser = colDiskQuotas.AddUser(domain)
set objUser = colDiskQuotas.FindUser(domain)
objUser.QuotaLimit = 1000000 * (Request("M_amwebspace"))
'Add Mail domain
Set obBaseApp = Server.CreateObject("hCOM.BaseApp")
Set obDomain = obBaseApp.Domains.Add
obdomain.Name = domain
obDomain.Active = True
obdomain.Save
'Add Default Mail user account admin@domain.com
sName = obBaseApp.Domains.ItemByName(domain).DomainID
Set obAccounts = obBaseApp.Domains.ItemByDBID(sName).Accounts.Add
obAccounts.Address = "admin@" & domain
obAccounts.Password = Request("M_password")
obAccounts.Active = True
obAccounts.MaxSize = 0
obAccounts.Save
'Send mail to administrator
body2me = "Register this domain : " & Request("M_domain") & VBCRLF & VBCRLF
body2me = body2me & "For : " & Request("M_name") & VBCRLF
body2me = body2me & "Address : " & Request("M_address") & VBCRLF
body2me = body2me & "Telephone : " & Request("M_telephone") & VBCRLF
body2me = body2me & "Email : " & Request("M_email")
Set mail2me = Server.CreateObject("JMail.Message")
mail2me.From = "admin@xxxx.co.uk"
mail2me.MailServerUserName = "xxx@xxx.com"
mail2me.MailServerPassword = "xxxxxx"
mail2me.Logging = True 'email address from sender
mail2me.AddRecipient "xxx@xxx.com" 'email address to student
mail2me.Subject = "!domain registration required!" 'subject of email
mail2me.body = body2me 'Body of email
mail2me.Send "mail.xxxxxxx.com"
' Send e-mail to new user
Body = "Dear " & Request("M_name") &"," & VBCRLF & VBCRLF
Body = Body & "Thank you for your recent order from Pulse Interactive. You opted to pay " & Request("M_payment") & "." & VBCRLF
Body = Body & "Your login details are as follows:" & VBCRLF
Body = Body & "Your web address: " & Request("M_domain") & VBCRLF
Body = Body & "Your ftp address: ftp." & Request("M_domain") & VBCRLF
Body = Body & "Your temporary FTP address: ftp://ftp.xxxx.co.uk/" & Request("M_domain") & "/" & VBCRLF
Body = Body & "Your temporary web address: [URL unfurl="true"]www.xxxx.co.uk/"[/URL] & Request("M_domain") & "/" & VBCRLF
Body = Body & "Your FTP username is : " & Request("M_domain") & VBCRLF
Body = Body & "Your FTP password is : " & Request("M_password") & VBCRLF & VBCRLF
Body = Body & "To log-in to the administration area please visit [URL unfurl="true"]http://admin.xxxx.co.uk[/URL] and enter your login details" & VBCRLF
Body = Body & "From here you can add/remove email addresses, databases and more... Your login information for this area is below" & VBCRLF
Body = Body & "Your Administration login is : admin@" & Request("M_domain") & VBCRLF
Body = Body & "Your Administration password is : " & Request("M_password") & VBCRLF
Body = Body & "This email address is also your 'catch-all' email address(please visit [URL unfurl="true"]http://mailadmin."[/URL] & Request("M_domain") &" to add/remove email accounts." & VBCRLF & VBCRLF
Body = Body & "To download mail on the move, why not use the webmail service located at [URL unfurl="true"]http://mail."[/URL] & Request("M_domain") & ". You can send and receive, even add attachments!" & VBCRLF & VBCRLF
Body = Body & "Thank you for your order. Please wait between 24-48 hours for the domain information to be propagated with xxxxxxxxxx" &VBCRLF
Body = Body & "Until then please test your site using the temporary addresses given" & VBCRLF & VBCRLF
Body = Body & " Kind Regards" & VBCRLF & VBCRLF
Body = Body & " Sales Dept." & VBCRLF & VBCRLF
Body = Body & " xxxxxx"
Dim usermailer
Set usermailer = Server.CreateObject("JMail.Message")
usermailer.From = "admin@xxxxx.co.uk"
usermailer.MailServerUserName = "xxxx@xxxx.com"
usermailer.MailServerPassword = "xxxx"
usermailer.Logging = True 'email address from sender
usermailer.AddRecipient Request("M_otheremail") 'email address to student
usermailer.Subject = "xxxxxxx hosting package order" 'subject of email
usermailer.body = Body 'Body of email
usermailer.Send "mail.xxxxx.com"%>
Any help would be most appreciated!!!
Thanks