ONJava.com -- The Independent Source for Enterprise Java
oreilly.comSafari Books Online.Conferences.

advertisement

AddThis Social Bookmark Button
Article:
  ASP.NET Forms Authentication, Part 2
Subject:   VB Version of this code.
Date:   2006-04-30 12:45:43
From:   erolsensoy
Thanks for simple and easy code. i'm take advantage this and working good. But i must use VB version of this code. i did translate to Vb version. May any visitors will take advantage.


Thanks.


// CODE STARTED HERE //


<%@ Import Namespace="System.Web.Security" %>
<%@ Import Namespace="System.Runtime.InteropServices" %>
<html>
<script language="VB" runat=server>
Declare Auto Function LogonUser Lib "advapi32.dll" _
(ByVal lpszUserName As String, _
ByVal lpszDomain As String, _
ByVal lpszPassword As String, _
ByVal dwLogonType As Integer, _
ByVal dwLogonProvider As Integer, _
ByRef phToken As Integer) As Integer

Public Const LOGON32_LOGON_INTERACTIVE As Integer = 2
Public Const LOGON32_PROVIDER_DEFAULT As Integer = 0


Protected Sub Login_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Dim token As Integer
If (LogonUser(UserName.Value, _
UserDomain.Value, _
UserPass.Value, _
LOGON32_LOGON_INTERACTIVE, _
LOGON32_PROVIDER_DEFAULT, _
token) <> 0) Then
Session("useractive") = "active"
FormsAuthentication.RedirectFromLoginPage(UserName.Value, False)
Else
Session("useractive") = "notactive"
lblResults.Text = "Username and/or Password is wrong. Try Again."
End If
End Sub


Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
UserName.Value = "MYUSERNAME" ' Not needed. require for only default value
UserDomain.Value = "MYDOMAIN" ' Not needed. require for only default value
End Sub
</script>


// CODE END HERE


1 to 1 of 1
  1. RE: VB Version of this code.
    2006-07-25 07:02:12  AlohaMora [View]

1 to 1 of 1