Cual es la mejor manera de hacer un shell

30/07/2004 - 10:37 por Sergiou | Informe spam
Hola a todos, estamos creando unos ensamblados con clases capaces de
crear sitios web en iis, hay algunos comandos para usar desde la linea
de comandos para ello, por lo que los componentes que estamos
programando generan un string que es el comando a ejecutar, el problema
es que cuando el procedimiento NewSite() llega a la linea donde se debe
ejecutar el Shell salta con una FileNotFoundException no lo puedo
entender puesto que el mismo comando que genera la clase ejecutado desde
la linea de comandos no falla.

Gracias por todo.

Preguntas similare

Leer las respuestas

#1 Sergiou
30/07/2004 - 13:00 | Informe spam
Lo he conseguido con la clase process, pero ahora me gustaría
establecer permisos de administrador al ejecutar el shell, sabéis como
es posible???

Sergiou wrote:
Mostrar la cita
#2 Sergiou
03/08/2004 - 13:57 | Informe spam
lo consegui y funciona

<%@ Page Language="VB" %>
<%@ Import Namespace = "System.Web" %>
<%@ Import Namespace = "System.Web.Security" %>
<%@ Import Namespace = "System.Security.Principal" %>
<%@ Import Namespace = "System.Runtime.InteropServices" %>

<script runat=server>
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, _
ImpersonationLevel As Integer, _
ByRef DuplicateTokenHandle As IntPtr) As Integer

Public Sub Page_Load(s As Object, e As EventArgs)
If impersonateValidUser("username", "domain", "password") Then
'Inserta aquí el código que se ejecuta bajo el contexto de
seguridad de un usuario específico.
undoImpersonation()
Else
'Su representación falló. Por tanto, incluya aquí un mecanismo a
prueba de error.
End If
End Sub

Private Function impersonateValidUser(userName As String, _
domain As String, 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
Private Sub undoImpersonation()
impersonationContext.Undo()
End Sub
</script>

Sergiou wrote:

Mostrar la cita
Ads by Google
Search Busqueda sugerida