VMWare 컴퓨터에서 실행되는 ASP.NET 응용 프로그램에서 도메인 사용자로 자신을 가장해야합니다. VMWare 시스템 자체가 도메인에 없으므로 ASP.NET은 web.config에 지정된 사용자 토큰을 확인할 수 없습니다. 그렇게 할 수있는 방법이 있습니까? 사전에ASP.NET : VMWare에서 도메인에 가장
감사합니다, 페트르
VMWare 컴퓨터에서 실행되는 ASP.NET 응용 프로그램에서 도메인 사용자로 자신을 가장해야합니다. VMWare 시스템 자체가 도메인에 없으므로 ASP.NET은 web.config에 지정된 사용자 토큰을 확인할 수 없습니다. 그렇게 할 수있는 방법이 있습니까? 사전에ASP.NET : VMWare에서 도메인에 가장
감사합니다, 페트르
나는 항상이 글을 쓰고 있으며, 매력처럼 작동한다!
//Run task as the impersonated user and not as NETWORKSERVICE or ASPNET (in IIS5)
try{
impersonate.Impersonate();
//Do work that needs to run as domain user here...
}
finally
{
//Revert impersonation to NETWORKSERVICE or ASPNET
if (impersonate != null)
{
impersonate.Undo();
impersonate.Dispose();
}
}
행운을 빕니다 :
using System;
using System.Security.Principal;
/// <summary>
/// Changes the security context the application runs under.
/// </summary>
public class ImpersonateHelper : IDisposable
{
[System.Runtime.InteropServices.DllImport("Kernel32")]
private extern static Boolean CloseHandle(IntPtr handle);
private IntPtr _token = IntPtr.Zero;
private WindowsImpersonationContext _impersonatedUser = null;
public IntPtr Token
{
get { return _token; }
set { _token = value; }
}
public ImpersonateHelper(IntPtr token)
{
_token = token;
}
/// <summary>
/// Switch the user to that set by the Token property
/// </summary>
public void Impersonate()
{
if (_token == IntPtr.Zero)
_token = WindowsIdentity.GetCurrent().Token;
_impersonatedUser = WindowsIdentity.Impersonate(_token);
}
/// <summary>
/// Revert to the identity (user) before Impersonate() was called
/// </summary>
public void Undo()
{
if (_impersonatedUser != null)
_impersonatedUser.Undo();
}
#region IDisposable Members
private bool _isDisposed;
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
protected virtual void Dispose(bool disposing)
{
if (!_isDisposed)
{
if (disposing)
{
if (_impersonatedUser != null)
_impersonatedUser.Dispose();
}
CloseHandle(_token);
_token = IntPtr.Zero;
}
_isDisposed = true;
}
~ImpersonateHelper()
{
Dispose(false);
}
#endregion
}
그런 다음 당신은 클라이언트 클래스에서 호출!
이 바보 분명한 해답이 될 수 있지만 도메인에 VM웨어 기계를 추가 할 수 있습니다.
도메인 관리 권한이없는 경우에는 안됩니다. – saschabeaumont
도메인 관리자 권한이 없지만 상사가 권한을가집니다. 내가하는 일은 문제가 해결 될 때까지는 더 이상 일을 할 수 없다는 것입니다. 결과적으로 내 가상 시스템이 상당히 빠르게 추가됩니다. –
보안 및 비용이 저렴한이 솔루션을 사용하는 것이 안전하지 않습니까? –