1. Complete Plesk Sitebuilder setup and register the administrator account.
2. Configure IIS as follows:
3. Place the script to the working directory.
<%@ language="VBScript" %>
<html>
<head>
<title>Creating Site Builder Account</title>
</head>
<body>
<%
dim baseUrl, adminLogin, adminPassword, newAccountId, newSiteId
dim error
baseUrl="http://localhost:2006"
adminLogin="admin"
adminPassword="admin"
newSiteId=Request("siteId")
if Request("action") = "create" then
newAccountId=CreateAccount(Request("accountName"), Request("accountPassword"), Request("firstName"), Request("lastName"), Request("eMail"), Request("plan"))
if newAccountId <> "" then
if newSiteId<>"" then
if true=TakeOwnerShip(newAccountId, newSiteId, Request("siteAlias")) then
RenderSuccess Request("accountName"), Request("accountPassword"), newSiteId
end if
else
newSiteId=CreateSite(newAccountId,Request("siteAlias"))
if newSiteId<>"" then
end if
end if
end if
else
response.Write RenderForm
end if
%>
</body>
</html>
<%
Function CreateAccount (accountName, accountPassword, firstName, lastName, eMail, planId)
dim url, xmlhttp, XMLDOM, XMLNode
' Call web service using HTTP-POST
url = baseUrl & "/ServiceFacade/4.1/AccountWebService.asmx"
Set xmlhttp = Server.CreateObject("MSXML2.ServerXMLHTTP")
Call xmlhttp.Open("POST", url, False)
Call xmlhttp.setRequestHeader("Content-Type", "application/soap+xml; charset=utf-8")
dim body
body = "<?xml version=""1.0"" encoding=""utf-8""?>"
body = body & "<soap12:Envelope xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"" xmlns:soap12=""http://www.w3.org/2003/05/soap-envelope"">"
body = body & "<soap12:Header>"
body = body & "<CredentialsSoapHeader xmlns=""http://parallels.com/webservices/sb/4.1/AccountService"">"
body = body & "<Login>" & adminLogin & "</Login>"
body = body & "<Password>" & adminPassword & "</Password>"
body = body & "</CredentialsSoapHeader>"
body = body & "</soap12:Header>"
body = body & "<soap12:Body>"
body = body & "<CreateAccount xmlns=""http://parallels.com/webservices/sb/4.1/AccountService"">"
body = body & "<ownerAccountId></ownerAccountId>"
body = body & "<username>" & accountName & "</username>"
body = body & "<password>" & accountPassword & "</password>"
body = body & "<firstName>" & firstName & "</firstName>"
body = body & "<lastName>" & lastName & "</lastName>"
body = body & "<email>" & eMail & "</email>"
body = body & "<role>SiteOwner</role>"
body = body & "<planId>" & planId & "</planId>"
body = body & "<changePasswordAllowed>true</changePasswordAllowed>"
body = body & "</CreateAccount>"
body = body & "</soap12:Body>"
body = body & "</soap12:Envelope>"
Call xmlhttp.send(body)
' Parse result
Set XMLDOM = Server.CreateObject("Microsoft.XMLDOM")
XMLDOM.Load(xmlhttp.responseBody)
Set XMLNode = XMLDOM.SelectSingleNode("//soap:Body")
CreateAccount = XMLDOM.xml 'XMLNode.xml
if Not XMLNode Is Nothing then
Dim XMLdata
Set XMLdata = XMLNode.firstChild
if Not XMLdata is Nothing then
if XMLData.nodeName = "soap:Fault" then
response.Write "FAULT!<br><pre>" & XMLData.text & "</pre>"
CreateAccount=""
else
Set XMLData = XMLDOM.SelectSingleNode("//CreateAccountResponse/UserAccount/AccountId")
CreateAccount = XMLData.text
end if
else
CreateAccount=""
response.Write "Error parsing SOAP response"
end if
end if
End Function
Function TakeOwnerShip(accountId, siteId, siteAlias)
dim url, xmlhttp, XMLDOM, XMLNode
' Call web service using HTTP-POST
url = baseUrl & "/ServiceFacade/4.1/SiteWebService.asmx"
Set xmlhttp = Server.CreateObject("MSXML2.ServerXMLHTTP")
Call xmlhttp.Open("POST", url, False)
Call xmlhttp.setRequestHeader("Content-Type", "application/soap+xml; charset=utf-8")
dim body
body = "<?xml version=""1.0"" encoding=""utf-8""?>"
body = body & "<soap12:Envelope xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"" xmlns:soap12=""http://www.w3.org/2003/05/soap-envelope"">"
body = body & "<soap12:Header>"
body = body & "<CredentialsSoapHeader xmlns=""http://parallels.com/webservices/sb/4.1/SiteService"">"
body = body & "<Login>" & adminLogin & "</Login>"
body = body & "<Password>" & adminPassword & "</Password>"
body = body & "</CredentialsSoapHeader>"
body = body & "</soap12:Header>"
body = body & "<soap12:Body>"
body = body & "<TakeOwnershipOfAnonymousSite xmlns=""http://parallels.com/webservices/sb/4.1/SiteService"">"
body = body & "<siteId>" & siteId & "</siteId>"
body = body & "<ownerId>" & accountId & "</ownerId>"
body = body & "<alias>" & siteAlias & "</alias>"
body = body & "</TakeOwnershipOfAnonymousSite>"
body = body & "</soap12:Body>"
body = body & "</soap12:Envelope>"
Call xmlhttp.send(body)
' Parse result
TakeOwnerShip=false
Set XMLDOM = Server.CreateObject("Microsoft.XMLDOM")
XMLDOM.Load(xmlhttp.responseBody)
Set XMLNode = XMLDOM.SelectSingleNode("//soap:Body")
if Not XMLNode Is Nothing then
Dim XMLdata
Set XMLdata = XMLNode.firstChild
if Not XMLdata is Nothing then
if XMLData.nodeName = "soap:Fault" then
response.Write "FAULT!<br><pre>" & XMLData.text & "</pre>"
else
TakeOwnerShip=true
end if
else
response.Write "Error parsing SOAP response"
end if
end if
End Function
Function ListPlans()
dim url, xmlhttp, XMLDOM, XMLNodeList, x , str
' Call web service using HTTP-POST
url = baseUrl & "/ServiceFacade/4.1/PlanWebService.asmx"
Set xmlhttp = Server.CreateObject("MSXML2.ServerXMLHTTP")
Call xmlhttp.Open("POST", url, False)
Call xmlhttp.setRequestHeader("Content-Type", "application/soap+xml; charset=utf-8")
dim body
body = "<?xml version=""1.0"" encoding=""utf-8""?>"
body = body & "<soap12:Envelope xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"" xmlns:soap12=""http://www.w3.org/2003/05/soap-envelope"">"
body = body & "<soap12:Header>"
body = body & "<CredentialsSoapHeader xmlns=""http://parallels.com/webservices/sb/4.1/PlanService"">"
body = body & "<Login>" & adminLogin & "</Login>"
body = body & "<Password>" & adminPassword & "</Password>"
body = body & "</CredentialsSoapHeader>"
body = body & "</soap12:Header>"
body = body & "<soap12:Body>"
body = body & "<GetAvailablePlans xmlns=""http://parallels.com/webservices/sb/4.1/PlanService"">"
body = body & "<accountId></accountId>"
body = body & "</GetAvailablePlans>"
body = body & "</soap12:Body>"
body = body & "</soap12:Envelope>"
Call xmlhttp.send(body)
' Parse result
Set XMLDOM = Server.CreateObject("Microsoft.XMLDOM")
XMLDOM.Load(xmlhttp.responseBody)
Set XMLNodeList = XMLDOM.selectNodes("//PlanValue")
For x = 1 To XMLNodeList.length
str = str & "<option value=""" & XMLNodeList.Item(x - 1).selectSingleNode("PlanId").text & """>" & XMLNodeList.Item(x - 1).selectSingleNode("Name").text
Next
ListPlans=str
End Function
Function CreateSite(ownerId, siteAlias)
dim url, xmlhttp, XMLDOM, XMLNode
' Call web service using HTTP-POST
url = baseUrl & "/ServiceFacade/4.1/SiteWebService.asmx"
Set xmlhttp = Server.CreateObject("MSXML2.ServerXMLHTTP")
Call xmlhttp.Open("POST", url, False)
Call xmlhttp.setRequestHeader("Content-Type", "application/soap+xml; charset=utf-8")
dim body
body = "<?xml version=""1.0"" encoding=""utf-8""?>"
body = body & "<soap12:Envelope xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"" xmlns:soap12=""http://www.w3.org/2003/05/soap-envelope"">"
body = body & "<soap12:Header>"
body = body & "<CredentialsSoapHeader xmlns=""http://parallels.com/webservices/sb/4.1/SiteService"">"
body = body & "<Login>" & adminLogin & "</Login>"
body = body & "<Password>" & adminPassword & "</Password>"
body = body & "</CredentialsSoapHeader>"
body = body & "</soap12:Header>"
body = body & "<soap12:Body>"
body = body & "<CreateSite xmlns=""http://parallels.com/webservices/sb/4.1/SiteService"">"
body = body & "<siteType>Regular</siteType>"
body = body & "<siteAlias>" & siteAlias & "</siteAlias>"
body = body & "<ownerId>" & ownerId & "</ownerId>"
body = body & "</CreateSite >"
body = body & "</soap12:Body>"
body = body & "</soap12:Envelope>"
Call xmlhttp.send(body)
' Parse result
Set XMLDOM = Server.CreateObject("Microsoft.XMLDOM")
XMLDOM.Load(xmlhttp.responseBody)
Set XMLNode = XMLDOM.SelectSingleNode("//soap:Body")
if Not XMLNode Is Nothing then
Dim XMLdata
Set XMLdata = XMLNode.firstChild
if Not XMLdata is Nothing then
if XMLData.nodeName = "soap:Fault" then
response.Write "FAULT!<br><pre>" & XMLData.text & "</pre>"
CreateSite=""
else
Set XMLData = XMLDOM.SelectSingleNode("//CreateSiteResponse/CreateSiteResult/Id")
CreateSite = XMLData.text
end if
else
CreateSite=""
response.Write "Error parsing SOAP response"
end if
end if
End Function
%>
<%
function RenderSuccess (login, password, siteId)
dim adminUrl, wizardUrl
adminUrl=baseUrl & "/ExternalLogin.ashx?Login=" & login & "&Password=" & password
wizardUrl=adminUrl & "&SiteID=" & siteId
adminUrl=adminUrl & "&ShowAdmin=true"
%>
You have successfully registered. Please <a href="<%=wizardUrl%>">click here</a> to edit your site at Wizard or <a href="<%=adminUrl%>">click here</a> to enter Plesk Sitebuilder siteowner's panel.
<%
End function
%>
<%
function RenderForm
%>
<h3>
SAMPLE CODE FOR PLESK SITEBUILDER INTEGRATION</h3>
Copyright© 2008 by <a href="parallels.com">Parallels</a><br>
NOTE: This code is provided as is, without any warranty, either express or implied
Please do not use this sample in a production environment WARNING! Administrator
credentials are sent in clear text. It is by default assumed that this script will
be run on the same machine as the Plesk Sitebuilder installation. In case you want to
administer the Plesk Sitebuilder remotely using this Web Service API, make sure to secure
the communication (for example, by using HTTPS protocol instead of HTTP).
<form method="post">
<input type="hidden" name="siteId" value="<% response.Write newSiteId%>" />
<table>
<tr>
<td>
Account Name:
</td>
<td>
<input type="text" name="accountName" value="TestUserFromASP"></td>
</tr>
<tr>
<td>
Account Password:
</td>
<td>
<input type="text" name="accountPassword" value="111111"></td>
</tr>
<tr>
<td>
First Name:
</td>
<td>
<input type="text" name="firstName" value="Bob"></td>
</tr>
<tr>
<td>
Last Name:
</td>
<td>
<input type="text" name="lastName" value="Smith"></td>
</tr>
<tr>
<td>
E-Mail:</td>
<td>
<input type="text" name="eMail" value="none@nowhere.org"></td>
</tr>
<tr>
<td>
Plan:
</td>
<td>
<select name="plan">
<%response.Write ListPlans() %>
</select>
</td>
</tr>
<tr><td colspan="2"><hr /></td></tr>
<tr>
<td>
Site alias:
</td>
<td>
<input type="text" name="siteAlias" value="Test Site">
</td>
</tr>
<tr>
<td colspan="2">
<input type="submit" name="action" value="create"></td>
</tr>
</table>
</form>
<%
End function
%>
4. Create the required plans in the Plesk Sitebuilder Administrator Panel.
5. Open TestSbIntegration.asp in a text editor and edit the following lines (11-13):
6. In Plesk Sitebuilder Administrator Panel, open Server -> Trial Site Settings -> Publish step message and edit the message with the following text, specifying the correct path to TestIntegration.asp:
<p align=center>Your temporary site will be available for a sb:lifetime at sb:sitepreviewlink</p><hr><p align=center>If you want to save it, please <a href="http://<yourserver>/<yourpath>/TestSbIntegration.asp?siteId=sb:siteid">register</a></p>