473,398 Members | 2,525 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

Impersonation wont work to remote server

Hi
I am trying to develop an web application that should use netsh dhcp to show information about our dhcp scope. The problem is that our dhcp server is different from our IIS (iis6).
I am trying to do this command via impersonation but I can't get the permissons to be right. I constantly get permission denied.
Below are the code used to execute the command and impersonation, is there anyone who know how to solve thos problem?
Best Regards Henrik Alstersjö
<Code>
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If LogonUser(Session("User"), "RD", Session("Passw"), 3, LOGON32_PROVIDER_DEFAULT, token) = True Then
Dim tomte As String
Dim oImpContext As System.Security.Principal.WindowsImpersonationCont ext
oImpContext = System.Security.Principal.WindowsIdentity.Imperson ate(token)
Response.Write(System.Security.Principal.WindowsId entity.GetCurrent().Name.ToString)
Dim proc As New System.Diagnostics.Process()

proc.StartInfo.FileName = "netsh"
proc.StartInfo.Arguments = "dhcp server \\semldsw2dhc078 show scope"
proc.StartInfo.UseShellExecute = False
proc.StartInfo.RedirectStandardOutput = True
proc.Start()
TextBox1.Text = proc.StandardOutput.ReadToEnd.ToString
proc.Close()
proc.Dispose()
oImpContext.Undo()
Else
Response.Write(System.Security.Principal.WindowsId entity.GetCurrent().Name.ToString)
TextBox1.Text = "Det gick fel"
End If

End Sub
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

Const LOGON32_LOGON_INTERACTIVE As Long = 2
Const LOGON32_LOGON_NETWORK As Long = 3
Const LOGON32_PROVIDER_DEFAULT As Long = 0
Const LOGON32_PROVIDER_WINNT50 As Long = 3
Const LOGON32_PROVIDER_WINNT40 As Long = 2
Const LOGON32_PROVIDER_WINNT35 As Long = 1

Dim token As IntPtr

</Code>
Nov 18 '05 #1
1 1388
Hallo Alstersjo
"Alstersjo" <Al*******@discussions.microsoft.com> schrieb im Newsbeitrag
news:70**********************************@microsof t.com...
Hi
I am trying to develop an web application that should use netsh dhcp to show information about our dhcp scope. The problem is that our dhcp server
is different from our IIS (iis6). I am trying to do this command via impersonation but I can't get the permissons to be right. I constantly get permission denied. Below are the code used to execute the command and impersonation, is there anyone who know how to solve thos problem? Best Regards Henrik Alstersjö
<Code>
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click If LogonUser(Session("User"), "RD", Session("Passw"), 3, LOGON32_PROVIDER_DEFAULT, token) = True Then Dim tomte As String
Dim oImpContext As System.Security.Principal.WindowsImpersonationCont ext oImpContext = System.Security.Principal.WindowsIdentity.Imperson ate(token) Response.Write(System.Security.Principal.WindowsId entity.GetCurrent().Name.T
oString) Dim proc As New System.Diagnostics.Process()

proc.StartInfo.FileName = "netsh"
proc.StartInfo.Arguments = "dhcp server \\semldsw2dhc078 show scope" proc.StartInfo.UseShellExecute = False
proc.StartInfo.RedirectStandardOutput = True
proc.Start()
TextBox1.Text = proc.StandardOutput.ReadToEnd.ToString
proc.Close()
proc.Dispose()
oImpContext.Undo()
Else
Response.Write(System.Security.Principal.WindowsId entity.GetCurrent().Name.T
oString) TextBox1.Text = "Det gick fel"
End If

End Sub
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

Const LOGON32_LOGON_INTERACTIVE As Long = 2
Const LOGON32_LOGON_NETWORK As Long = 3
Const LOGON32_PROVIDER_DEFAULT As Long = 0
Const LOGON32_PROVIDER_WINNT50 As Long = 3
Const LOGON32_PROVIDER_WINNT40 As Long = 2
Const LOGON32_PROVIDER_WINNT35 As Long = 1

Dim token As IntPtr

</Code>


I think the problem could be that Diagnostics.Process.Start starts a process
in the security context of the parent process, which is "aspnet_wp.exe" i
think. there a several workarounds, im fighting with one right now (topic:
Calling CreateProcessWithLogonW).

regards benni
Nov 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: CJ | last post by:
Hi anyone. Does anyone know of issues regarding impersonation in VB .NET with regards to accessing remote WMI information? I have a wrapper class which encapsulates various WMI calls, this...
1
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...
12
by: Anil Krishnamurthy | last post by:
We have an ASP.NET application that uses COM objects through Interop. The web application requires access to network and database resources and hence, needs to impersonate a domain account. The...
2
by: Jon L. Lovesky | last post by:
Hello all, I am attempting to access a remote folder from an asp.net application (all within the same domain). The application is configured for windows authentication in IIS and the asp.net...
2
by: Sharon | last post by:
Hi to all. I have two Impersonation problems: 1. When using my app. from a remote computer, the aspx page is unable to get information from Active Directory. I am using Impersonation, and the...
15
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...
26
by: andrew_webby at hotmail | last post by:
Hi Am having a problem with an app I wrote to test patch delivery. I contact a remote PC, and get it to run a patch which is installed on a server. It works fine if I use psexec for example and...
4
by: Backwards | last post by:
Hey everybody I'm having a little trouble getting access to a few commands in our 65 odd SQL databases. Have had a chat to our DBA's and they wont give my windows account access and they also...
0
by: cbtg2006 | last post by:
HI guys, I'm relatively new to the .net development realm. I am creating an application in vb.net to monitor services on remote servers. The application works great when I am logged in and...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
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
1
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...
0
marktang
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,...
0
Oralloy
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,...
0
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...
0
tracyyun
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.