BSW.Blog

Simple ASP Page To Change HmailServer Password For Clients


<%
On Error resume next 

if request("Do")="Error" then 
    Select Case Request("Type")
    case "Account"
    %>
    <html><head><title>Password Change</title></head><body><p>Bad Account</p> <p><a href='?' >Back</a></p></body></html>
    <%
    case "Change"
    %>
    <html><head><title>Password Change</title></head><body><p>Can't Change</p> <p><a href='?' >Back</a></p></body></html>
    <%
    
    Case "Password"
    %>
    <html><head><title>Password Change</title></head><body><p>Bad Password</p> <p><a href='?' >Back</a></p></body></html>
    <%
    Case "Confirm"
    %>
    <html><head><title>Password Change</title></head><body><p>Password Confirmation Issue</p> <p><a href='?' >Back</a></p></body></html>
    <%
    case else 
    %>
    <html><head><title>Password Change</title></head><body><p>Unknown Error</p> <p><a href='?' >Back</a></p></body></html>
    <%
    
    end select 
    response.End 
end if 
if request("Do")="ChangePassword" then 
    Dim obApp
    Set obApp = CreateObject("hMailServer.Application")
    Call obApp.Authenticate(request("Email"), request("OldPassword"))
    if err.number<>0 then
        response.Redirect("?Do=Error&Type=Password")
        response.End
        
    end if 
     
    Dim obDomain
    Set obDomain = obApp.Domains.ItemByName(Split(request("Email"),"@")(1))
    
    if err.number<>0 then
   ' response.Write err.Description
        response.Redirect("?Do=Error&Type=Password")
        response.End
        
    end if 
    if trim(Request("PasswordConf"))<>"" and  Request("PasswordConf")=Request("Password")then
        Dim obAccount
        Set obAccount = obDomain.Accounts.ItemByAddress(request("Email"))

        if err.number<>0 then
            response.Redirect("?Do=Error&Type=Account")
            response.End
        end if 
         obAccount.Password=Request("Password")
          obAccount.Save
        if err.number<>0 then
            response.Redirect("?Do=Error&Type=Change")
            response.End
        end if 
        
        Response.Write ("<html><head><title>Password Changed</title></head><body><p>Password Changed</p> <p><a href='?' >Back</a></p></body></html>")
        Response.End ()
    else 
        response.Redirect("?Do=Error&Type=Confirm")
        response.End
    end if 
 end if 
%>
<!DOCTYPE html>
<html>
<head>
<title>Change Password </title>
<style type="text/css">
/*************************************************/
/*By Babak                                       */
.SimpleTable
{
    padding-left: auto;
    padding-right: auto;
    margin-left: auto;
    margin-right: auto;
    border: solid thin black;
    border-collapse: collapse;
}
.SimpleTable th, .SimpleTable thead
{
    font-size: 14px;
    background-color: #882222;
    color: #AAAA22;
}
.SimpleTable th, .SimpleTable td
{
    text-align: center;
    border: solid thin black;
    padding: 1px 10px 1px 10px;
    margin: 0px 0px 0px 0px;
}</style>
</head>
<body>
    <form action="?Do=ChangePassword" method="post">
    <table class=SimpleTable>
        <tr>
            <th colspan="2">
                Change Password
            </th>
        </tr>
        <tr>
            <th>
                Email
            </th>
            <td>
                <input name="Email" type="Email" />
            </td>
        </tr>
        <tr>
            <th>
                Old Password
            </th>
            <td>
                <input name="OldPassword" type="password" />
            </td>
        </tr>
        <tr>
            <th>
                New Password
            </th>
            <td>
                <input name="Password" type="password" />
            </td>
        </tr>
        <tr>
            <th>
                New Password (Confirm)
            </th>
            <td>
                <input name="PasswordConf" type="password" />
            </td>
        </tr>
        <tr>
            <td colspan="2">
                <input type="submit" />
            </td>
        </tr>
    </table>
    </form>
</body>
</html>

Some Steps Needed To Permit ASP to Use HmailServer Com Class:

Steps

Follow these steps to give IIS or Apache the required permissions to connect to hMailServer using DCOM.

  1. Start DCOM config by selecting Start, Run, enter dcomcnfg.exe and press OK.
  2. In the Component Services program, expand the Component Services folder
  3. Expand down to Computers | My Computer | DCOM Config
  4. Right-click on hMailServer and select properties
  5. Select the Security tab
  6. Under "Launch and Activation Permissions", select Customize and click on Edit
  7. Under "Group or user names", click Add
  8. For IIS6: add the built-in anonymous IIS user account
  9. For Apache: add the Apache user account
  10. Set the Local Launch and Local Activation permissions for this user to Allow

* Italic Content From https://www.hmailserver.com/documentation/v5.3/index.php?page=howto_dcom_permissions

Babak
#free #Server #hmail #hmailServer #Config #Script #ASP #Programming #VB #Visual Basic #Server Admin #Admin #Tools #password #Change Password
12/31/2014 10:18:35 AM
Write Comment