protected void Page_Load(object sender, EventArgs e)
        {
            hMailServerNetRemote.IClassFactory cf = RemoteActivation.GetRemoteClassFactory("http://216.167.175.124/hMailServerWebAdmin/");

            hMailServerNetRemote.IApplication application;
            if (Session["hMailServerNetRemoteApplication"] == null)
            {
                application = cf.CreateApplication();
                Session["hMailServerNetRemoteApplication"] = application;
            }
            else
            {
                application = (hMailServerNetRemote.Application)Session["hMailServerNetRemoteApplication"];
            }

            // the rest is the same
            application.Authenticate("Administrator", "testar");

            // You can do it like VB, but let's do it the C# way. :)
            // hMailServerNetRemote.Domain domain = application.Domains.ItemByName("example.com");
            hMailServerNetRemote.IDomain domain = application.Domains["example.com"];

            hMailServerNetRemote.IAccount account = domain.Accounts.ItemByAddress("*****@*****.**");
            account.Password = "******";
            account.Save();
        }
Beispiel #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                hMailServerNetRemote.IApplication app = RemoteActivation.GetAuthenticatedRemotehMailServerApplication();
                if (app == null)
                {
                    Response.End();
                }

                hMailServerNetRemote.IDomain dom = app.Domains.ItemByDBID(Convert.ToInt32(Request.QueryString["ID"]));

                DomainName.Text = dom.Name;

                List <hMailServerNetRemote.IDistributionList> dls = new List <hMailServerNetRemote.IDistributionList>();
                hMailServerNetRemote.IDistributionLists       d   = dom.DistributionLists;
                int c = d.Count;

                for (int i = 0; i < c; i++)
                {
                    dls.Add(d[i]);
                }

                DistributionList.DataSource = dls;
                DistributionList.DataBind();
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            hMailServerNetRemote.IApplication app = RemoteActivation.GetAuthenticatedRemotehMailServerApplication();
            if (app == null)
            {
                Response.End();
            }

            hMailServerNetRemote.IDomain dom = app.Domains.ItemByDBID(Convert.ToInt32(Request.QueryString["ID"]));

            if (!IsPostBack)
            {
                DomainName.Text               = dom.Name;
                Enabled.Checked               = dom.Active;
                AccountLink.NavigateUrl       = "~/Admin/Accounts.aspx?ID=" + Request.QueryString["ID"];
                Aliases.NavigateUrl           = "~/Admin/DomainAliases.aspx?ID=" + Request.QueryString["ID"];
                DistributionLists.NavigateUrl = "~/Admin/DistributionLists.aspx?ID=" + Request.QueryString["ID"];
            }
            else
            {
                dom.Name   = DomainName.Text;
                dom.Active = Enabled.Checked;
                dom.Save();
            }
        }
Beispiel #4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            hMailServerNetRemote.IApplication app = RemoteActivation.GetAuthenticatedRemotehMailServerApplication();
            if (app == null)
            {
                Response.End();
            }

            string[] sp = Request.QueryString["Address"].Split(new Char[] { '@' });
            if (sp.Length != 2)
            {
                Response.StatusCode = 404;
                Response.End();
            }

            hMailServerNetRemote.IDomain domain = app.Domains.ItemByName(sp[1]);
            if (domain == null)
            {
                Response.StatusCode = 404;
                Response.End();
            }

            hMailServerNetRemote.IDistributionList ds = domain.DistributionLists.ItemByAddress(Request.QueryString["Address"]);
            if (ds == null)
            {
                Response.StatusCode = 404;
                Response.End();
            }

            hMailServerNetRemote.IDistributionListRecipients re = ds.Recipients;

            if (!IsPostBack)
            {
                DistributionListName.Text = ds.Address;

                List <hMailServerNetRemote.IDistributionListRecipient> addys = new List <hMailServerNetRemote.IDistributionListRecipient>();
                int c = re.Count;
                for (int i = 0; i < c; i++)
                {
                    addys.Add(re[i]);
                }

                AddressList.DataSource = addys;
                AddressList.DataBind();
            }
        }
        //
        // System.Web.Security.MembershipProvider methods.
        //

        //
        // MembershipProvider.ChangePassword
        //

        public override bool ChangePassword(string username, string oldPwd, string newPwd)
        {
            if (!ValidateUser(username, oldPwd))
            {
                return(false);
            }

            ValidatePasswordEventArgs args =
                new ValidatePasswordEventArgs(username, newPwd, true);

            OnValidatingPassword(args);

            if (args.Cancel)
            {
                if (args.FailureInformation != null)
                {
                    throw args.FailureInformation;
                }
                else
                {
                    throw new MembershipPasswordException("Change password canceled due to new password validation failure.");
                }
            }

            string[] sp = username.Split(new Char[] { '@' });

            if (sp.Length != 2)
            {
                return(false);
            }

            hMailServerNetRemote.IApplication app     = RemoteActivation.GetRemotehMailServerApplication();
            hMailServerNetRemote.IDomain      domain  = app.Domains.ItemByName(sp[1]);
            hMailServerNetRemote.IAccount     account = domain.Accounts[username];
            account.Password = newPwd;
            account.Save();

            return(true);
        }
        //
        // GetUserFromReader
        //    A helper function that takes the current row from the MySqlDataReader
        // and hydrates a MembershiUser from the values. Called by the
        // MembershipUser.GetUser implementation.
        //

        private hMailServerNetRemote.IAccount GetAccount(string email)
        {
            hMailServerNetRemote.IApplication app = RemoteActivation.GetRemotehMailServerApplication();
            string[] sp = email.Split(new Char[] { '@' });

            if (sp.Length != 2)
            {
                return(null);
            }

            hMailServerNetRemote.IDomain domain = app.Domains.ItemByName(sp[1]);
            if (domain == null)
            {
                return(null);
            }

            hMailServerNetRemote.IAccount account = domain.Accounts.ItemByAddress(email);
            if (account == null)
            {
                return(null);
            }

            return(account);
        }