首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VB >

江湖急救!该怎么处理

2012-01-02 
江湖急救!求教300行左右用vb写的代码,附带基本的解释。[解决办法]我送你1000行的Example Name:Authenticat

江湖急救!
求教300行左右用vb写的代码,附带基本的解释。

[解决办法]
我送你1000行的
'Example Name:Authenticating a User though the NT Challenge Process 

'------------------------------------------
'
' Form Code
'
'------------------------------------------
Option Explicit

Private Const SEC_E_OK = 0
Private Const HEAP_ZERO_MEMORY = &H8
Private Const SEC_WINNT_AUTH_IDENTITY_ANSI = &H1
Private Const SECBUFFER_TOKEN = &H2
Private Const SECURITY_NATIVE_DREP = &H10
Private Const SECPKG_CRED_INBOUND = &H1
Private Const SECPKG_CRED_OUTBOUND = &H2
Private Const SEC_I_CONTINUE_NEEDED = &H90312
Private Const SEC_I_COMPLETE_NEEDED = &H90313
Private Const SEC_I_COMPLETE_AND_CONTINUE = &H90314
Private Const VER_PLATFORM_WIN32_NT = &H2

Private Type SecPkgInfo
fCapabilities As Long
wVersion As Integer
wRPCID As Integer
cbMaxToken As Long
Name As Long
Comment As Long
End Type

Private Type SecHandle
dwLower As Long
dwUpper As Long
End Type

Private Type AUTH_SEQ
fInitialized As Boolean
fHaveCredHandle As Boolean
fHaveCtxtHandle As Boolean
hcred As SecHandle
hctxt As SecHandle
End Type

Private Type SEC_WINNT_AUTH_IDENTITY
User As String
UserLength As Long
Domain As String
DomainLength As Long
Password As String
PasswordLength As Long
Flags As Long
End Type

Private Type SEC_WINNT_AUTH_IDENTITYL
User As Long
UserLength As Long
Domain As Long
DomainLength As Long
Password As Long
PasswordLength As Long
Flags As Long
End Type

Private Type TimeStamp
LowPart As Long
HighPart As Long
End Type

Private Type SecBuffer
cbBuffer As Long
BufferType As Long
pvBuffer As Long
End Type

Private Type SecBufferDesc
ulVersion As Long
cBuffers As Long
pBuffers As Long
End Type

Private Type OSVERSIONINFO
OSVSize As Long
dwVerMajor As Long
dwVerMinor As Long
dwBuildNumber As Long
PlatformID As Long
szCSDVersion As String * 128
End Type

Private Declare Sub CopyMemory Lib "kernel32" _
Alias "RtlMoveMemory" _
(Destination As Any, _
Source As Any, _
ByVal Length As Long)
 
Private Declare Function CompleteAuthToken Lib "secur32" _
(ByRef phContext As SecHandle, _
ByRef pToken As SecBufferDesc) As Long

Private Declare Function DeleteSecurityContext Lib "secur32" _
(ByRef phContext As SecHandle) As Long

Private Declare Function FreeCredentialsHandle Lib "secur32" _
(ByRef phContext As SecHandle) As Long
 
Private Declare Function FreeContextBuffer Lib "secur32" _
(ByVal pvContextBuffer As Long) As Long

Private Declare Function GetProcessHeap Lib "kernel32" () As Long

Private Declare Function HeapAlloc Lib "kernel32" _
(ByVal hHeap As Long, _
ByVal dwFlags As Long, _
ByVal dwBytes As Long) As Long

Private Declare Function HeapFree Lib "kernel32" _
(ByVal hHeap As Long, _
ByVal dwFlags As Long, _
ByVal lpMem As Long) As Long

Private Declare Function GetVersionEx Lib "kernel32" _
Alias "GetVersionExA" _
(lpVersionInformation As OSVERSIONINFO) As Long
 
Private Declare Function QuerySecurityPackageInfo Lib "secur32" _
Alias "QuerySecurityPackageInfoA" _
(ByVal PackageName As String, _


ByRef pPackageInfo As Long) As Long

Private Declare Function InitializeSecurityContext Lib "secur32" _
Alias "InitializeSecurityContextA" _
(phCredential As Any, _
phContext As Any, _
ByVal pszTargetName As Long, _
ByVal fContextReq As Long, _
ByVal Reserved1 As Long, _
ByVal TargetDataRep As Long, _
pInput As Any, _
ByVal Reserved2 As Long, _
phNewContext As SecHandle, _
pOutput As SecBufferDesc, _
pfContextAttr As Long, _
ptsExpiry As TimeStamp) As Long


[解决办法]

探讨
我送你1000行的
'Example Name:Authenticating a User though the NT Challenge Process

'------------------------------------------
'
' Form Code
'
'------------------------------------------
Option Explicit

Private Const SEC_E_OK = 0
Private Const HEAP_ZERO_MEMORY = &H8
Private Const SEC_WINNT_AUTH_IDENTITY_ANSI = &H1
Private Const SECBUFFER_TOKEN = &H2
Private Const SECURITY_NATIVE_DREP = &H10
Private Const SECPKG_CRED_INBOUND = &H1
Private Const SECPKG_CRED_OUTBOUND = &H2
Private Const SEC_I_CONTINUE_NEEDED = &H90312
Private Const SEC_I_COMPLETE_NEEDED = &H90313
Private Const SEC_I_COMPLETE_AND_CONTINUE = &H90314
Private Const VER_PLATFORM_WIN32_NT = &H2

Private Type SecPkgInfo
  fCapabilities As Long
  wVersion As Integer
  wRPCID As Integer
  cbMaxToken As Long
  Name As Long
  Comment As Long
End Type

Private Type SecHandle
    dwLower As Long
    dwUpper As Long
End Type

Private Type AUTH_SEQ
  fInitialized As Boolean
  fHaveCredHandle As Boolean
  fHaveCtxtHandle As Boolean
  hcred As SecHandle
  hctxt As SecHandle
End Type

Private Type SEC_WINNT_AUTH_IDENTITY
  User As String
  UserLength As Long
  Domain As String
  DomainLength As Long
  Password As String
  PasswordLength As Long
  Flags As Long
End Type

Private Type SEC_WINNT_AUTH_IDENTITYL
  User As Long
  UserLength As Long
  Domain As Long
  DomainLength As Long
  Password As Long
  PasswordLength As Long
  Flags As Long
End Type

Private Type TimeStamp
  LowPart As Long
  HighPart As Long
End Type

Private Type SecBuffer
  cbBuffer As Long
  BufferType As Long
  pvBuffer As Long
End Type

Private Type SecBufferDesc
  ulVersion As Long
  cBuffers As Long
  pBuffers As Long
End Type

Private Type OSVERSIONINFO
  OSVSize        As Long
  dwVerMajor      As Long
  dwVerMinor      As Long
  dwBuildNumber  As Long
  PlatformID      As Long
  szCSDVersion    As String * 128
End Type

Private Declare Sub CopyMemory Lib "kernel32" _
  Alias "RtlMoveMemory" _
  (Destination As Any, _
  Source As Any, _
  ByVal Length As Long)
 
Private Declare Function CompleteAuthToken Lib "secur32" _
  (ByRef phContext As SecHandle, _
  ByRef pToken As SecBufferDesc) As Long

Private Declare Function DeleteSecurityContext Lib "secur32" _
  (ByRef phContext As SecHandle) As Long

Private Declare Function FreeCredentialsHandle Lib "secur32" _
  (ByRef phContext As SecHandle) As Long


 
Private Declare Function FreeContextBuffer Lib "secur32" _
  (ByVal pvContextBuffer As Long) As Long

Private Declare Function GetProcessHeap Lib "kernel32" () As Long

Private Declare Function HeapAlloc Lib "kernel32" _
  (ByVal hHeap As Long, _
  ByVal dwFlags As Long, _
  ByVal dwBytes As Long) As Long

Private Declare Function HeapFree Lib "kernel32" _
  (ByVal hHeap As Long, _
  ByVal dwFlags As Long, _
  ByVal lpMem As Long) As Long

Private Declare Function GetVersionEx Lib "kernel32" _
  Alias "GetVersionExA" _
  (lpVersionInformation As OSVERSIONINFO) As Long
 
Private Declare Function QuerySecurityPackageInfo Lib "secur32" _
  Alias "QuerySecurityPackageInfoA" _
  (ByVal PackageName As String, _
  ByRef pPackageInfo As Long) As Long

Private Declare Function InitializeSecurityContext Lib "secur32" _
  Alias "InitializeSecurityContextA" _
  (phCredential As Any, _
  phContext As Any, _
  ByVal pszTargetName As Long, _
  ByVal fContextReq As Long, _
  ByVal Reserved1 As Long, _
  ByVal TargetDataRep As Long, _
  pInput As Any, _
  ByVal Reserved2 As Long, _
  phNewContext As SecHandle, _
  pOutput As SecBufferDesc, _
  pfContextAttr As Long, _
  ptsExpiry As TimeStamp) As Long


热点排行