%@ Language=VBScript %>
<% Option Explicit %>
<%
'-------------------------------------------------------------------------
' POP3 Mail Add-in - Master Settings
' Copyright (C) Microsoft Corporation. All rights reserved.
'-------------------------------------------------------------------------
%>
<%
'-------------------------------------------------------------------------
' Global Constants
'-------------------------------------------------------------------------
Dim SOURCE_FILE
SOURCE_FILE = SA_GetScriptFileName()
Const c_nMaxPort = 65535
Const FLD_AUTHENTICATION = "fldAuthentication"
Const FLD_PORT = "fldPort"
Const FLD_LOGGING = "fldLogging"
Const FLD_MAILROOT = "fldMailRoot"
Const FLD_REQUIRESPA = "fldRequireSPA"
Const FLD_SERVICERESTART = "fldServiceRestart"
Const SERVICE_RESTART_NONE = 0
Const SERVICE_RESTART_POP3SVC = 1
Const SERVICE_RESTART_POP3SVC_SMTP = 2
Const SERVICE_CONTROL_STOP = 1
'-------------------------------------------------------------------------
' Global Variables
'-------------------------------------------------------------------------
Dim g_page
Dim g_nAuthentication
Dim g_nPort
Dim g_nLoggingLevel
Dim g_strMailRoot
Dim g_bSPARequired
Dim g_nDomains
Dim g_iServiceRestart
'----------------------------------------------------------------------
' Global Localized Strings
'----------------------------------------------------------------------
Dim l_strPageTitle
l_strPageTitle = GetLocString(RES_DLL_NAME, _
POP3_PAGETITLE_MASTERSETTINGS, _
"")
Dim l_strCaptionAuthentication
l_strCaptionAuthentication = GetLocString(RES_DLL_NAME, _
POP3_CAPTION_MASTERSETTINGS_AUTHENTICATION, _
"")
Dim l_astrAuthentication(3)
l_astrAuthentication(AUTH_AD) = GetLocString(RES_DLL_NAME, _
POP3_AUTHENTICATION_ACTIVEDIRECTORY, _
"")
l_astrAuthentication(AUTH_SAM) = GetLocString(RES_DLL_NAME, _
POP3_AUTHENTICATION_WINDOWSACCOUNTS, _
"")
l_astrAuthentication(AUTH_FILE) = GetLocString(RES_DLL_NAME, _
POP3_AUTHENTICATION_FILE, _
"")
Dim l_strCaptionPort
l_strCaptionPort = GetLocString(RES_DLL_NAME, _
POP3_CAPTION_MASTERSETTINGS_PORT, _
"")
Dim l_strCaptionLoggingLevel
l_strCaptionLoggingLevel = GetLocString(RES_DLL_NAME, _
POP3_CAPTION_MASTERSETTINGS_LOGGING, _
"")
Dim l_astrLogging(3)
l_astrLogging(LOGGING_NONE) = GetLocString(RES_DLL_NAME, _
POP3_LOGGING_NONE, _
"")
l_astrLogging(LOGGING_MINIMUM) = GetLocString(RES_DLL_NAME, _
POP3_LOGGING_MINIMUM, _
"")
l_astrLogging(LOGGING_MEDIUM) = GetLocString(RES_DLL_NAME, _
POP3_LOGGING_MEDIUM, _
"")
l_astrLogging(LOGGING_MAXIMUM) = GetLocString(RES_DLL_NAME, _
POP3_LOGGING_MAXIMUM, _
"")
Dim l_strCaptionMailRoot
l_strCaptionMailRoot = GetLocString(RES_DLL_NAME, _
POP3_CAPTION_MASTERSETTINGS_MAILROOT, _
"")
Dim l_strConfirmNewMailRoot
l_strConfirmNewMailRoot = GetLocString(RES_DLL_NAME, _
POP3_PROMPT_MAILROOTCONFIRM, _
"")
Dim l_strConfirmPOP3ServiceRestart
l_strConfirmPOP3ServiceRestart = GetLocString(RES_DLL_NAME, _
POP3_PROMPT_SERVICERESTART_POP3SVC, _
"")
Dim l_strConfirmPOP3SMTPServiceRestart
l_strConfirmPOP3SMTPServiceRestart = GetLocString(RES_DLL_NAME, _
POP3_PROMPT_SERVICERESTART_POP3SVC_SMTP, _
"")
Dim l_strCaptionRequireSPA
l_strCaptionRequireSPA = GetLocString ( RES_DLL_NAME, _
POP3_CAPTION_MASTERSETTINGS_REQUIRESPA, _
"" )
Dim l_strErrInvalidPort
l_strErrInvalidPort = GetLocString(RES_DLL_NAME, _
POP3_E_INVALIDPORT, _
"")
'**********************************************************************
'* E N T R Y P O I N T
'**********************************************************************
Call SA_CreatePage(l_strPageTitle, "", PT_PROPERTY, g_page)
Call SA_ShowPage (g_page)
'**********************************************************************
'* H E L P E R S U B R O U T I N E S
'**********************************************************************
'---------------------------------------------------------------------
' ServeCommonJavaScript
'---------------------------------------------------------------------
Function ServeCommonJavaScript()
%>
<%
End Function
'**********************************************************************
'* E V E N T H A N D L E R S
'**********************************************************************
'---------------------------------------------------------------------
' OnInitPage
'---------------------------------------------------------------------
Public Function OnInitPage(ByRef PageIn, ByRef EventArg)
On Error Resume Next
OnInitPage = TRUE
Dim oConfig
Set oConfig = Server.CreateObject("P3Admin.P3Config")
g_nLoggingLevel = oConfig.LoggingLevel
g_strMailRoot = oConfig.MailRoot
g_nPort = CLng(oConfig.Service.Port)
g_nAuthentication = oConfig.Authentication.CurrentAuthMethod
g_nDomains = oConfig.Domains.Count
g_bSPARequired = oConfig.Service.SPARequired
g_iServiceRestart = CInt(SERVICE_RESTART_NONE)
If (Err.number <> 0) Then
Call SA_SetErrMsg( HandleUnexpectedError() )
End If
End Function
'---------------------------------------------------------------------
' OnServePropertyPage
'---------------------------------------------------------------------
Public Function OnServePropertyPage(ByRef PageIn, ByRef EventArg)
On Error Resume Next
'
' Emit Javascript functions required by Web Framework
Call ServeCommonJavaScript()
OnServePropertyPage = TRUE
'
' Disable the authentication dropdown unless no domains have been
' created for this server.
'
Dim strAuthenticationDisabled
If (g_nDomains > 0) Then
strAuthenticationDisabled = "DISABLED"
Else
strAuthenticationDisabled = ""
End If
Dim strSelected ' Used to select the current value in the dropdowns below.
strSelected = ""
Dim oConfig, iType, iCount
Dim iAuthFileType
iAuthFileType = -1
Set oConfig = Server.CreateObject("P3Admin.P3Config")
iCount = oConfig.Authentication.Count
For iType = 1 To iCount
If ( AUTH_FILE = oConfig.Authentication.Item(CLng(iType)).ID ) Then
iAuthFileType = iCount
End If
Next
%>
<%
If (Err.number <> 0) Then
Call SA_SetErrMsg( HandleUnexpectedError() )
End If
End Function
'---------------------------------------------------------------------
' OnPostBackPage
'---------------------------------------------------------------------
Public Function OnPostBackPage(ByRef PageIn, ByRef EventArg)
On Error resume next
OnPostBackPage = TRUE
Dim oConfig
Set oConfig = Server.CreateObject("P3Admin.P3Config")
'
' Get the authentication method, if it wasn't disabled. Otherwise,
' just get the current value from the Config object.
'
If (Request.Form(FLD_AUTHENTICATION).Count > 0) Then
g_nAuthentication = CInt(Request.Form(FLD_AUTHENTICATION).Item(1))
Else
g_nAuthentication = oConfig.Authentication.CurrentAuthMethod
End If
'
' Get the rest of the form values.
'
If ( StrComp(Request.Form(FLD_REQUIRESPA), "on", vbTextCompare) = 0 ) Then
g_bSPARequired = True
Else
g_bSPARequired = False
End If
g_nPort = CLng(Request.Form(FLD_PORT).Item(1))
g_nLoggingLevel = CInt(Request.Form(FLD_LOGGING).Item(1))
g_strMailRoot = CStr(Request.Form(FLD_MAILROOT).Item(1))
g_iServiceRestart = CInt(Request.Form(FLD_SERVICERESTART).Item(1))
g_nDomains = oConfig.Domains.Count
If (Err.number <> 0) Then
Call SA_SetErrMsg( HandleUnexpectedError() )
End If
End Function
'---------------------------------------------------------------------
' OnSubmitPage
'---------------------------------------------------------------------
Public Function OnSubmitPage(ByRef PageIn, ByRef EventArg)
On Error Resume Next
Dim oConfig, oAuthMethods
Set oConfig = Server.CreateObject("P3Admin.P3Config")
Set oAuthMethods = oConfig.Authentication
' set Authmethod.
oAuthMethods.CurrentAuthMethod = CLng(g_nAuthentication)
oAuthMethods.Save ()
' set main settings
oConfig.LoggingLevel = g_nLoggingLevel
oConfig.MailRoot = g_strMailRoot
oConfig.Service.Port = CLng(g_nPort)
If ( g_bSPARequired = True ) Then
oConfig.Service.SPARequired = 1
Else
oConfig.Service.SPARequired = 0
End If
' cycle the services
If (Err.number = 0) Then
If ( SERVICE_RESTART_POP3SVC = g_iServiceRestart Or SERVICE_RESTART_POP3SVC_SMTP = g_iServiceRestart ) Then
If ( SERVICE_CONTROL_STOP <> oConfig.Service.POP3ServiceStatus ) Then
oConfig.Service.StopPOP3Service()
oConfig.Service.StartPOP3Service()
End If
End If
End If
If (Err.number = 0) Then
If ( SERVICE_RESTART_POP3SVC_SMTP = g_iServiceRestart ) Then
If ( SERVICE_CONTROL_STOP <> oConfig.Service.SMTPServiceStatus ) Then
oConfig.Service.StopSMTPService()
oConfig.Service.StartSMTPService()
End If
End If
End If
If (Err.number <> 0) Then
Call SA_SetErrMsg( HandleUnexpectedError() )
OnSubmitPage = FALSE
Else
OnSubmitPage = TRUE
End If
End Function
'---------------------------------------------------------------------
' OnClosePage
'---------------------------------------------------------------------
Public Function OnClosePage(ByRef PageIn, ByRef EventArg)
OnClosePage = TRUE
End Function
%>