Hello all,
I have a working example of Impersonation where I receive a token and a true
response for a specific user. However, if I try to access a drive that has
only that user's permission to access I get denied. Code below.
I tried this on a XP box and a W2K box with the same results. This
impersonation is in a Active Directory environment with W2K Server.
Thanks for any help
Bill
Dim LOGON32_LOGON_INTERACTIVE As Integer = 2
Dim LOGON32_PROVIDER_DEFAULT As Integer = 0
Dim impersonationContext As WindowsImpersonationContext
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 Integer
Declare Auto Function DuplicateToken Lib "advapi32.dll" (ByVal
ExistingTokenHandle As IntPtr, ByVal ImpersonationLevel As Integer, ByRef
DuplicateTokenHandle As IntPtr) As Integer
Private Function impersonateValidUser(ByVal userName As String, _
ByVal domain As String, ByVal password As String) As Boolean
Dim tempWindowsIdentity As WindowsIdentity
Dim token As IntPtr
Dim tokenDuplicate As IntPtr
If LogonUser(userName, domain, password, LOGON32_LOGON_INTERACTIVE, _
LOGON32_PROVIDER_DEFAULT, token) <> 0 Then
If DuplicateToken(token, 2, tokenDuplicate) <> 0 Then
tempWindowsIdentity = New WindowsIdentity(tokenDuplicate)
impersonationContext = tempWindowsIdentity.Impersonate()
If impersonationContext Is Nothing Then
impersonateValidUser = False
Else
impersonateValidUser = True
End If
Else
impersonateValidUser = False
End If
Else
impersonateValidUser = False
End If
End Function 1 1701
Hi, http://www.dotnet247.com/247referenc...28/144136.aspx
Ken
------------------
"William Oliveri" <wu**@bigvalley.net> wrote in message
news:OR****************@tk2msftngp13.phx.gbl... Hello all,
I have a working example of Impersonation where I receive a token and a
true response for a specific user. However, if I try to access a drive that
has only that user's permission to access I get denied. Code below.
I tried this on a XP box and a W2K box with the same results. This impersonation is in a Active Directory environment with W2K Server.
Thanks for any help
Bill Dim LOGON32_LOGON_INTERACTIVE As Integer = 2 Dim LOGON32_PROVIDER_DEFAULT As Integer = 0 Dim impersonationContext As WindowsImpersonationContext 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 Integer
Declare Auto Function DuplicateToken Lib "advapi32.dll" (ByVal ExistingTokenHandle As IntPtr, ByVal ImpersonationLevel As Integer, ByRef DuplicateTokenHandle As IntPtr) As Integer
Private Function impersonateValidUser(ByVal userName As String, _ ByVal domain As String, ByVal password As String) As Boolean
Dim tempWindowsIdentity As WindowsIdentity Dim token As IntPtr Dim tokenDuplicate As IntPtr If LogonUser(userName, domain, password, LOGON32_LOGON_INTERACTIVE, _ LOGON32_PROVIDER_DEFAULT, token) <> 0 Then If DuplicateToken(token, 2, tokenDuplicate) <> 0 Then tempWindowsIdentity = New WindowsIdentity(tokenDuplicate) impersonationContext = tempWindowsIdentity.Impersonate() If impersonationContext Is Nothing Then impersonateValidUser = False Else impersonateValidUser = True End If Else impersonateValidUser = False End If Else impersonateValidUser = False End If End Function
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: seandiaz |
last post by:
I have a question concerning impersonation - I created an app using
impersonation that runs fine on my local machine. I also ran the app on two
other developer machines and it runs fine. When I...
|
by: CyberDigger |
last post by:
I have two computers, client and server. The client is running Windows 2000
Professional and is in a workgroup, say "MyWorkgroup". The server is running
Windows Server 2003 Standard Edition and...
|
by: Tom Wells |
last post by:
My server admin and I are trying to figure out how to get impersonation
working to be able to upload a file from the client browser thru the web
server to a network file server. My network ID for...
|
by: Patrick |
last post by:
I set my web.config as follows:
<authentication mode="Windows" />
<identity impersonate="true" />
Logon to my ASP.NET website as a user who can authenticate to the target
database.
1) Works...
|
by: bennett |
last post by:
In order for my ASP.Net application to access a database using my
privileged account, I was told to set up an app using Integrated
Windows authentication and to use impersonation. I set the app to...
|
by: Phil |
last post by:
Hi,
I've currently setup a local user as described in:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnne...
|
by: David Cablalero |
last post by:
I have a windows service which every night checks a SQL Server database for
some data and business rules. The application can access different DBs with
the same structure, to tell the service which...
|
by: Elroyskimms |
last post by:
I need to execute a batch file via ASP.Net. In my VB.Net code, I'm
using System.Diagnostics.Process to call the batch file and its
appropriate command line arguments. I'm using...
|
by: Mike |
last post by:
Hi all,
Hopefully someone will be able to help with this issue. I have an
ASP.Net application that is trying to extract frames from .avi
and .wmv files to create thumbnails. The media files are...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |