• Introducing WebPros Cloud - a fully managed infrastructure platform purpose-built to simplify the deployment of WebPros products !  WebPros Cloud enables you to easily deliver WebPros solutions — without the complexity of managing the infrastructure.
    Join the pilot program today!
  • Support for BIND DNS has been removed from Plesk for Windows due to security and maintenance risks.
    If a Plesk for Windows server is still using BIND, the upgrade to Plesk Obsidian 18.0.70 will be unavailable until the administrator switches the DNS server to Microsoft DNS.

domains under user account

S

s58smith

Guest
Hello all, I'm brand new to using Plesk and little lost in the user configuration.

I have very clients but each one host hundreds of web sites. I'm used to other control panels where I build a user account and then add several domains under the single account. Every domain I create in Plesk keeps asking for a new FTP user. I want lots of domains to a single user. My largest user has over 600 domains hosted. I can't see setting him up with 600 separate FTP logins to take care of them.

I'm wanting to setup a single user account for each client to FTP into. Under their account directory it will have a directory for each domain.

Is there any way I can have Plesk setup to do this?
 
Nope, the one account that a client has that is shared between all domains is the login to plesk. beyond that, any account that wants to have physical hosting on the server has to create an FTP user, and that user has to be unique on the system.

Historically for some of our larger clients - ones that have over a thousand domains each - we have setup a script that runs to create each client account, associate each domain to a certain account, and automate the creation of the FTP accounts so the customer doesnt have to.
 
we have setup a script that runs to create each client account, associate each domain to a certain account, and automate the creation of the FTP accounts so the customer doesnt have to.

Is is possible you could share that script? I'm moving servers and control panels. Anything to help automate the process for the several 1000 domains I need to move will help greatly.

Thanks
 
Sure.... but Im not sure it will help you - its written in Dot **** (asp.net 2.0) and is a console application.
it will be run from your desktop and needs to be compiled before you can use it.

It reads from a text file called CreateSites.txt and reads in the accountID, domain, ftp user, and password.


In the format of
[ClientID],[domain name],[ftp user],[ftp password]

example:
2,domain.com.mysuer1,passwordabcd1234

I ran a seperate script to populate this and to randomly generate passwords, and create a username in the format of userXXX where XXX was a number - you can populate that stuff any way you like. it may be just as easy to ask the customer to provide you with a list of accounts they want, what domain assocaited to what account, ftp user names, etc.

PHP:
using System;
using System.Collections.Generic;
using System.Text;

namespace CreateSites
{
    class Program
    {
        static void Main(string[] args)
        {

            run r =  new run();
            r.Begin();
            r.End();
        }
    }
}

PHP:
using System;
using System.Net;
using System.Text;
using System.IO;
using System.Xml;
using System.Xml.Schema;
using System.Security.Cryptography.X509Certificates;
using System.Net.Security;
using System.Configuration;
using System.Collections;
using System.Collections.Specialized;

public partial class XmlSend
{
    public XmlSend()
    {
    }

    public XmlDocument Send(XmlDocument packet, string server)
    {
        HttpWebRequest request = SendRequest(packet.OuterXml, server);
        XmlDocument result = GetResponse(request);
        return result;
    }

    public XmlDocument Send(XmlDocument packet, string server, NameValueCollection nvc)
    {
        HttpWebRequest request = SendRequest(packet.OuterXml, server, nvc);
        XmlDocument result = GetResponse(request);
        return result;
    }

    private HttpWebRequest SendRequest(string message, string server, NameValueCollection nvc)
    {
        HttpWebRequest request = (HttpWebRequest)WebRequest.Create(server);
        request.Headers.Add(nvc);
        request.Method = "POST";
        request.ContentType = "text/xml";
        request.ContentLength = message.Length;

        ASCIIEncoding encoding = new ASCIIEncoding();
        byte[] buffer = encoding.GetBytes(message);

        using (Stream stream = request.GetRequestStream())
        {
            stream.Write(buffer, 0, message.Length);
        }

        return request;
    }

    private HttpWebRequest SendRequest(string message, string server)
    {
        HttpWebRequest request = (HttpWebRequest)WebRequest.Create(server);
        request.Method = "POST";
        request.ContentType = "text/xml";
        request.ContentLength = message.Length;

        ASCIIEncoding encoding = new ASCIIEncoding();
        byte[] buffer = encoding.GetBytes(message);

        using (Stream stream = request.GetRequestStream())
        {
            stream.Write(buffer, 0, message.Length);
        }

        return request;
    }

    private XmlDocument ParseAndValidate(TextReader xml)
    {
        XmlDocument document = new XmlDocument();
        using (XmlReader reader = XmlTextReader.Create(xml))
        {
            document.Load(reader);
        }

        return document;
    }

    private XmlDocument GetResponse(HttpWebRequest request)
    {
        using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
        using (Stream stream = response.GetResponseStream())
        using (TextReader reader = new StreamReader(stream))
        {
            return ParseAndValidate(reader);
        }
    }
}


PHP:
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Net;
using System.Text;
using System.IO;
using System.Xml;
using System.Xml.Schema;
using System.Security.Cryptography.X509Certificates;
using System.Net.Security;

namespace CreateSites
{

    class run
    {

        String ServerIP = "10.10.10.10";
        XmlDocument pagexmldoc = new XmlDocument();
        StreamReader oReader = new StreamReader("CreateSites.txt");
        StreamWriter writer = new StreamWriter("Results.txt");

        public void End()
        {

            try
            {
                writer.Close();
            }
            catch { }

            try
            {
                oReader.Close();
            }
            catch { }
                
        }

        public void Begin()
        {
			String sLine = String.Empty;
            while (sLine != null)
            {
                sLine = oReader.ReadLine();

                if (sLine != null)
                {
                    String sDomain, sClientID, FTPUser, FTPPassword;
                    String[] LineArr = sLine.Split(new char[] { ',' });

                    sClientID = LineArr[0];
                    sDomain = LineArr[1];
                    FTPUser = LineArr[2];
                    FTPPassword = LineArr[3];

                    String Packet = BuildXML(sDomain, sClientID, FTPUser, FTPPassword);
                    SendXMLRequest(sDomain, Packet);
                }

            }
        }

        private String BuildXML(String sDomain, String sClientID, String FTPUser, String FTPPassword )
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("<packet version=\"1.4.2.0\">");
            sb.Append("<domain>");
            sb.Append("<add>");
            sb.Append("   <gen_setup>");
            sb.AppendFormat("      <name>{0}</name>", sDomain);
            sb.AppendFormat("      <client_id>{0}</client_id>", sClientID);
            sb.Append("      <htype>vrt_hst</htype>");
            sb.Append("      <ip_address>10.7.30.19</ip_address>");
            sb.Append("      <status>0</status>");
            sb.Append("   </gen_setup>");
            //sb.Append("   <template-name>default</template-name>");
            sb.Append("                 <hosting>");
            sb.Append("                    <vrt_hst>");
            sb.AppendFormat("                        <ftp_login>{0}</ftp_login>", FTPUser);
            sb.AppendFormat("                        <ftp_password>{0}</ftp_password>", FTPPassword);
            sb.Append("                       <php>true</php>");
            sb.Append("                        <php_safe_mode>true</php_safe_mode>");
            sb.Append("                         <ip_address>10.7.30.19</ip_address>");
            sb.Append("                     </vrt_hst>");
            sb.Append("                  </hosting>");
            sb.Append("</add>");
            sb.Append("</domain>");
            sb.Append("</packet>");

            return sb.ToString();
        }

        private static bool RemoteCertificateValidation(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
        {
            if (sslPolicyErrors != SslPolicyErrors.RemoteCertificateNotAvailable)
                return true;

            Console.WriteLine("Certificate error: {0}", sslPolicyErrors);

            // Do not allow this client to communicate with unauthenticated servers.
            return false;
        }
        private void SendXMLRequest( String sDomain, String packet)
        {
            ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(RemoteCertificateValidation);
            XmlSend request = new XmlSend();
            XmlDocument xmldoc = new XmlDocument();

            try
            {
                xmldoc.LoadXml(packet);
            }
            catch
            {
                Console.WriteLine("Failed to build XML");
                return;
            }

            try
            {
                String sServer = String.Format("https://{0}:8443/enterprise/control/agent.php", ServerIP);
                XmlDocument result = null;
                NameValueCollection nvc = new NameValueCollection();
                nvc.Add("HTTP_AUTH_LOGIN", "admin");
                nvc.Add("HTTP_AUTH_PASSWD", "Frefr3ke");
                result = request.Send(xmldoc, sServer, nvc);

                String sResult = String.Empty;
                try
                {
                    sResult = result.DocumentElement.SelectSingleNode("/packet/domain/add/result/status").InnerText;

                    if (String.Compare(sResult, "ok", true) == 0)
                    {

                        Console.WriteLine("Domain {0} Success", sDomain);
                    }
                    else
                    {
                        Console.WriteLine("Domain {0} Failed - Error {1}", sDomain, result.DocumentElement.SelectSingleNode("/packet/domain/add/result/errtext").InnerText);
                        writer.WriteLine("Domain {0} Failed - Error {1}", sDomain, result.DocumentElement.SelectSingleNode("/packet/domain/add/result/errtext").InnerText);
                        return;
                    }
                }
                catch 
                {
                    writer.WriteLine(packet);
                }


            }
            catch (Exception e)
            {
                Console.Write("Error:: {0}", e.Message);
            }
        }

    }

}
 
Back
Top