BSW.Blog

Simple ASP Page To Change HmailServer Password For Clients


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
<%
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