<%
' *****************************************************************************
' File:		/NRConfig/AccessConfig/CNCASPPageManager_AccessConfig.inc
'
' Version: 	Microsoft Content Management Server
' Author:	Microsoft Corporation
' Purpose:	Contains ASP programming logic for the "Access" tab and 
'			configuration dialog for SCA.
'
' Implements the INCASPPageManager interface:
'	- Sub InitManager()
'	- Property Error
'	- Property ErrorDetails
'	- Property Dirty_flag
'
' Public Methods and Properties Exposed:
'	- Property ResServerIndex [readonly Long]
'	- Property NTSupportedDomains [readonly Collection]
'	- Property OnOKUrl [readonly String]
'	- Property IsSSLRunning [Readonly, Boolean] 
'	- Property IsLocalHost [Readonly, Boolean] 
'	- Property SecurityAlertURL [Readonly, String]
'
' *****************************************************************************

Const IDS_E_ACCESS_NO_RESSERVERINDEX = "No ResServerIndex Present"

Const IDS_ON_OK_URL = "/NRConfig/AccessConfig/AccessConfigDlgAcceptor/AccessConfigDlgAcceptor.asp"


Class CNCASPPageManager_AccessConfigDlg

	Public Error
	Public ErrorDetails
	Public Dirtyflag	
	
	Private m_nResServerIndex
	Private m_pSCAPI
	
	Private m_colNTSupportedDomains
	
	Private m_strOnOKUrl
	
	Private m_bIsSSLRunning
	Private m_bIsLocalHost
	Private m_strSecurityAlertURL

	' ---- [Private] Class standard initialize
    Private Sub Class_Initialize()
    
        Error = ""
		ErrorDetails = ""
	    DirtyFlag = "false"
	
    	m_nResServerIndex = 0
    	Set m_pSCAPI = Nothing
    	
		Set m_colNTSupportedDomains = Nothing
		
		m_strOnOKUrl = IDS_ON_OK_URL
		
		m_bIsLocalHost = False
		m_bIsSSLRunning = False

		Call ChkIsLocalHostConnection()
		Call SetupSSLRunningFlag()
		
		m_strSecurityAlertURL = "\NRConfig\SecurityAlert\SecurityAlert.asp?" & "ResServerIndex=" & Request.QueryString("ResServerIndex")
    End Sub 

	' ---- [Public] CNCASPPageManager standard init method
	Public Sub InitManager()
		If GetResServerIndex() = False Then
			Exit Sub
		End If

		Call InitializeDataFromSCAPI()
	End Sub
	
	' ---- [Public] The MCMS for communicating with the server
	Property Get ResServerIndex()
		ResServerIndex = m_nResServerIndex
	End Property 
	
	' ---- [Public] Whether or not this is loaded locally
	Property Get IsLocalHost()
		IsLocalHost = m_bIsLocalHost
	End Property 
	
	' ---- [Public] Whether or not this is loaded via SSL
	Property Get IsSSLRunning()
		IsSSLRunning = m_bIsSSLRunning
	End Property 
	
	' ---- [Public] URL to security alert page
	Property Get SecurityAlertURL()
		SecurityAlertURL = m_strSecurityAlertURL
	End Property 
	
	' ---- [Public] Collection of supported NT Domains
	Property Get NTSupportedDomains()
	
		Set NTSupportedDomains = m_colNTSupportedDomains
		
		If Err.Number <> 0 Then
			Error = IDS_UNEXPEXTED_ERROR & " " & "Failed to get User Authentication Settings."
			ErrorDetails = Err.Description 			
		End If
	
	End Property

	' ---- [Public] Return the OnOKUrl
	Property Get OnOKUrl()
		OnOKUrl = m_strOnOKUrl
	End Property	
	
 	' ---- [Private] Chk if we are using LocalHost
	Private Sub ChkIsLocalHostConnection()
	
		Dim strRemoteHost
		Dim strLocalHost
	
		strRemoteHost = CStr(Request.ServerVariables(IDS_ACCESS_REMOTE_ADDR))
		strLocalHost = CStr(Request.ServerVariables(IDS_ACCESS_LOCAL_ADDR))
	
		If (strLocalHost = IDS_LOCAL_HOST_ID) OR (strRemoteHost = IDS_LOCAL_HOST_ID) OR _
		   (strLocalHost = strRemoteHost) Then
			m_bIsLocalHost = True
		End If
	End Sub



   	' ---- [Private] Chk is SSL is running
	Private Sub SetupSSLRunningFlag()
	
		Dim strSSLStatus 
	
		strSSLStatus = CStr(Request.ServerVariables(IDS_ACCESS_HTTPS))
	
		If strSSLStatus = "on" Then
			m_bIsSSLRunning = True
		End If

	End Sub
	
	' ---- [Private] Retrieve the ResServerIndex we need for communication with SCAPI; return success flag.
	Private Function GetResServerIndex()
		If ( Request.QueryString("ResServerIndex") <> "" ) Then
			m_nResServerIndex = CLng( Request.QueryString("ResServerIndex") )
			GetResServerIndex = True
		Else
			Error = IDS_E_ACCESS_NO_RESSERVERINDEX
			GetResServerIndex = False
		End If
	End Function

	' ---- [Private] Initialize various setting by querying SCAPI
	Private Sub InitializeDataFromSCAPI()
	   	On Error Resume Next

	   	Set m_pSCAPI = Server.CreateObject("ServerConfigurationAPI.NRSCAPI")
		Call m_pSCAPI.Initialize()
		
		' -- retrieve Authrntication setting object
		Dim pUserAuthenticationSettings, pNTSetting
		Set pUserAuthenticationSettings = m_pSCAPI.UserAuthenticationSettings( m_nResServerIndex )
		
		'--Error Check
		If Err.Number <> 0 Then
			Error = IDS_UNEXPEXTED_ERROR & " " & IDS_UI_ERROR_GET_USER_AUTH_SETTINGS
			ErrorDetails = Err.Description 
			Exit Sub
		End If
		
		' -- retrieve NT Domains setting
		Set pNTSetting = pUserAuthenticationSettings.NT
		
		'--Error Check
		If Err.Number <> 0 Then
			Error = IDS_UNEXPEXTED_ERROR & " " & IDS_UI_ERROR_GET_USER_AUTH_SETTINGS_FOR_NT
			ErrorDetails = Err.Description 
			Exit Sub
		End If
		
		Set m_colNTSupportedDomains = pNTSetting.SupportedNTDomains
		
		'--Error Check
		If Err.Number <> 0 Then
			Error = IDS_UNEXPEXTED_ERROR &  " " & IDS_UI_ERROR_GET_SPPORTED_NT_DOMAINS
			ErrorDetails = Err.Description 
			Exit Sub
		End If
		
	End Sub
	

End Class

%>