tam olarak kullanmanız gereken accesstoken. Bunu elde etmek için LogonUser yöntemini çağırmanız gerekir:
oops sadece VB.net koduna sahip olduğumu anlamadı.
Private 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 IntPtr) As Boolean
ve yürütmeyi:
_Token = New IntPtr(0)
Const LOGON32_PROVIDER_DEFAULT As Integer = 0
'This parameter causes LogonUser to create a primary token.
Const LOGON32_LOGON_INTERACTIVE As Integer = 2
Const LOGON32_LOGON_NEWCREDENTIALS As Integer = 9
_Token = IntPtr.Zero
' Call LogonUser to obtain a handle to an access token.
Dim returnValue As Boolean = LogonUser(_User, _Domain, _Password, LOGON32_LOGON_NEWCREDENTIALS, LOGON32_PROVIDER_DEFAULT, _Token)
If False = returnValue Then
Dim ret As Integer = Marshal.GetLastWin32Error()
Console.WriteLine("LogonUser failed with error code : {0}", ret)
Throw New System.ComponentModel.Win32Exception(ret)
End If
_Identity = New WindowsIdentity(_Token)
_Context = _Identity.Impersonate()
şifre olmadan bunu yapmak için bir yolu var mı advapi32.dll gelen
LogonUser
çağırmak/p kullan? Kimliğe bürünmeden hemen önce yarattığım için ona erişimim var, sadece sormamı düşündüm. – DougSanırım "CloseHandle" ("LogonUser" için dokümanlar) bölümünde belirtildiği gibi (https://msdn.microsoft.com/en-us/library/windows/desktop/aa378184 (v = vs.85) .aspx)) using bloktan sonra 'userToken' için. Veya bu, WindowsIdentity tarafından bir şekilde denir mi? – CodeFox
Merhaba Bu ASP.NET Uygulaması ise, bunun kapsamı nedir? Her sayfada bu işlevi çağırmalı mıyım? –