一般来说IIS的验证方式有好几种,比较常见的就是匿名验证,集成Windows验证等等。 但是集成Windows验证每次都会谈个对话框出来,很麻烦,特别是在使用代理的情况下。
于是想能不能用一种Form的方式实现Windows验证呢? 当然啦,想想而已,本来对WEB开发就不算熟, Windows方面的就更差了。
在网上搜索到了一种方式,利用 advapi32.dll的LogonUser方法是可以验证你输入的用户名密码是不是Windows的有效用户的。
代码如下 :
'include permissions namespace for security attributes
'include principal namespace for windowsidentity class
'include interopservices namespace for dllImports.
Imports System.Security.Principal
Imports System.Security.Permissions
Imports System.Runtime.InteropServices
'
Public Class LogInUser
_
Private Shared Function LogonUser(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