作者:VB.NET开发
项目:System.Web.ClientServices.Provider
Private Function ValidateUsingCredentialsProvider() As Boolean
Dim isAuthorized As Boolean = False
Try
Dim authProvider As ClientFormsAuthenticationMembershipProvider = _
CType(System.Web.Security.Membership.Provider, _
ClientFormsAuthenticationMembershipProvider)
' Call ValidateUser with empty strings in order to display the
' login dialog box configured as a credentials provider.
isAuthorized = authProvider.ValidateUser(String.Empty, String.Empty)
Catch ex As System.Net.WebException
MessageBox.Show("Unable to access the authentication service.", _
"Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning)
End Try
If Not isAuthorized Then
MessageBox.Show("Unable to authenticate.", "Not logged in", _
MessageBoxButtons.OK, MessageBoxIcon.Error)
Application.Exit()
End If
Return isAuthorized
End Function
作者:VB.NET开发
项目:System.Web.ClientServices.Provider
Private Function ValidateUsingLoginControls() As Boolean
Dim isAuthorized As Boolean = False
Try
Dim authProvider As ClientFormsAuthenticationMembershipProvider = _
CType(System.Web.Security.Membership.Provider, _
ClientFormsAuthenticationMembershipProvider)
' Call ValidateUser with credentials retrieved from login controls.
isAuthorized = authProvider.ValidateUser(usernameTextBox.Text, _
passwordTextBox.Text, rememberMeCheckBox.Checked)
Catch ex As System.Net.WebException
MessageBox.Show("Unable to access the authentication service.", _
"Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning)
End Try
If Not isAuthorized Then
MessageBox.Show("Unable to authenticate.", "Not logged in", _
MessageBoxButtons.OK, MessageBoxIcon.Error)
Application.Exit()
End If
Return isAuthorized
End Function
作者:VB.NET开发
项目:System.Web.ClientServices.Provider
Private Function ValidateUsingServiceUri(ByVal serviceUri As String) As Boolean
Dim isAuthorized As Boolean = False
Try
' Call the Shared overload of ValidateUser. Specify credentials
' retrieved from login controls and the service location.
isAuthorized = _
ClientFormsAuthenticationMembershipProvider.ValidateUser( _
usernameTextBox.Text, passwordTextBox.Text, serviceUri)
Catch ex As System.Net.WebException
MessageBox.Show("Unable to access the authentication service.", _
"Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning)
End Try
If Not isAuthorized Then
MessageBox.Show("Unable to authenticate.", "Not logged in", _
MessageBoxButtons.OK, MessageBoxIcon.Error)
Application.Exit()
End If
Return isAuthorized
End Function