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(); }
// // MembershipProvider.ResetPassword // public override string ResetPassword(string username, string answer) { if (!EnablePasswordReset) { throw new NotSupportedException("Password reset is not enabled."); } if (answer == null && RequiresQuestionAndAnswer) { UpdateFailureCount(username, "passwordAnswer"); throw new ProviderException("Password answer required for password reset."); } string newPassword = System.Web.Security.Membership.GeneratePassword(newPasswordLength, MinRequiredNonAlphanumericCharacters); ValidatePasswordEventArgs args = new ValidatePasswordEventArgs(username, newPassword, true); OnValidatingPassword(args); if (args.Cancel) { if (args.FailureInformation != null) { throw args.FailureInformation; } else { throw new MembershipPasswordException("Reset password canceled due to password validation failure."); } } hMailServerNetRemote.IAccount account = GetAccount(username); if (account == null) { throw new ProviderException("Can't find user"); } account.Password = newPassword; account.Save(); return(newPassword); }
// // 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); }