Back To: DotNetNuke Silverlight IWebXAML
'
' DotNetNukeŽ - http://www.dotnetnuke.com
' Copyright (c) 2002-2007
' by DotNetNuke Corporation
'
' Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
' documentation files (the "Software"), to deal in the Software without restriction, including without limitation
' the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
' to permit persons to whom the Software is furnished to do so, subject to the following conditions:
'
' The above copyright notice and this permission notice shall be included in all copies or substantial portions
' of the Software.
'
' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
' TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
' THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
' CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
' DEALINGS IN THE SOFTWARE.
'
Imports System.Web.Services.Protocols
Imports System.Diagnostics
Imports System.Reflection
Imports DotNetNuke.Services.Personalization
Namespace DotNetNuke.Modules.IWebXAML
' class that is passed in through the soap header
Public Class IWebXAMLAuthendicationHeader
Public PortalID As Integer
Public UserID As Integer
Public Password As String
Public Username As String
Public ModuleId As Integer
End Class
Public Class IWebXAMLAuthendication
' const values
Private Class Consts
Public Const LoginErrorMessage As String = "Login failed. Invalid credentials supplied to the web service method."
End Class
Private _MethodName As String
Private _PortalID As Integer
Private _UserID As Integer
Private _Password As String
Private _Username As String
Private _ModuleId As Integer
#Region "Constructors"
Public Sub New(ByVal IWebCredentials As IWebXAMLAuthendicationHeader)
_PortalID = IWebCredentials.PortalID
_ModuleId = IWebCredentials.ModuleId
_UserID = IWebCredentials.UserID
_Password = IWebCredentials.Password
End Sub
#End Region
Public Function IsUserValid() As Boolean
Dim loginStatus As Security.Membership.UserLoginStatus
Dim strEncryptionKey As String
' Get the Key from Personalization
Dim PersonalizationController As New PersonalizationController()
Dim PersonalizationInfo As New PersonalizationInfo()
PersonalizationInfo = PersonalizationController.LoadProfile(_UserID, _PortalID)
If Not Personalization.GetProfile(PersonalizationInfo, _ModuleId.ToString, "SilverlightKey") Is Nothing Then
If CType(Personalization.GetProfile(PersonalizationInfo, _ModuleId.ToString, "SilverlightKey_Expires"), DateTime) < DateTime.Now() Then
'Expired Encryption Key
Return False
End If
strEncryptionKey = CType(Personalization.GetProfile(PersonalizationInfo, _ModuleId.ToString, "SilverlightKey"), String)
If _Password = strEncryptionKey Then
Dim SilverlightUser As New UserInfo()
SilverlightUser = UserController.GetUser(_PortalID, _UserID, False)
_Password = UserController.GetPassword(SilverlightUser, "").ToString()
_Username = SilverlightUser.Username
Else
Return False
End If
End If
Dim objUser As UserInfo = UserController.ValidateUser(_PortalID, _Username, _Password, "", "", "255.255.255.1", loginStatus)
If objUser Is Nothing Then
Return False
Else
Return True
End If
End Function
Public Function GetUserInfo() As UserInfo
Dim loginStatus As Security.Membership.UserLoginStatus
Return UserController.ValidateUser(_PortalID, _Username, _Password, "", "", "255.255.255.1", loginStatus)
End Function
End Class
End Namespace