Windows 인증을 사용하고 일반적으로 기본 IIS 사용자로 실행되는 ASP.NET 4.0 인트라넷 사이트가 있습니다. 나는 인증 된 사용자를 가장하고 그들을 대신하여 행동하고 싶습니다. 특히 해당 사용자가 도메인 관리자 인 경우 인트라넷 페이지에서 여러 서버에서 실행되는 서비스를 모니터링하고 해당 서비스를 시작 및 중지하고 해당 서버를 다시 부팅 할 수 있기를 바랍니다.Windows 인증을 사용하여 ASP.NET 인트라넷 사이트를 사용하여 네트워크상의 컴퓨터를 관리합니다.
지금까지 인증 된 사용자를 가장하기 위해 컨텍스트를 전환 할 수 있으며 사용자의 AD 그룹을 검사하여 도메인 관리자인지 확인할 수 있습니다. 내가 다른 서버에서 실행중인 서비스의 상태를 확인하려고 할 때, 나는 다음과 같은 오류가 발생합니다 :
Cannot open Service Control Manager on computer 'MyServer'. This operation might require other privileges. ---> System.ComponentModel.Win32Exception: Access is denied
은 로컬 Visual Studio에서 잘 작동합니다. 하지만 인트라넷 사이트가 내부 웹 서버에 배포되는시기는 아닙니다. Page_Load
에서
내가 이렇게 :
'Switch from IIS User to the currently authenticated Admin user
Dim impersonationContext As WindowsImpersonationContext = Nothing
Dim authenticatedIdentity As WindowsIdentity = DirectCast(HttpContext.Current.User.Identity, WindowsIdentity)
impersonationContext = authenticatedIdentity.Impersonate()
그리고 다음 GridView
의 RowDataBound
경우에, 나는이 작업을 수행 :
'Check if service exists and is running
Dim arrServices() As ServiceController = ServiceController.GetServices(machineName)
If Not arrServices.Any(Function(o) o.ServiceName = SERVICE_NAME) Then
' Service is missing...
Else
Dim oServiceController As New ServiceController(SERVICE_NAME, machineName)
If oServiceController.Status = ServiceControllerStatus.Running Then
' Service is running...
Else
' Service has stopped...
End If
End If
가 어떻게 사용하여 사용자를 대신하여 다른 서버를 관리 할 수 있습니다 이 인트라넷 사이트의 Windows 인증?
코드가 실제로 자동으로 처리를 중지하지는 않습니다. 아마도 당신은 질문에 관련 코드를 보여 주어야합니다. – mason
@mason 제 수정 된 질문을 참조하십시오. 나는 그 오류를 억제하려고 시도 잡았어. 진짜 오류 메시지를 지금보십시오. – John