[英]What is the magic to Windows impersonation with LOGON32_LOGON_NEW_CREDENTIALS?
[英]“Access is Denied” LOGON32_LOGON_SERVICE
我正在尝试使用advapi32
模拟网络服务
LogonUser("NETWORK SERVICE", "NT AUTHORITY", null, LOGON32_LOGON_SERVICE, LOGON32_PROVIDER_DEFAULT, ref token)
但在Windows 8计算机上继续获取Access is denied
错误。 有任何想法吗? (我google了很多但找不到答案)。
<asmv1:assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1" xmlns:asmv1="urn:schemas-microsoft-com:asm.v1" xmlns:asmv2="urn:schemas-microsoft-com:asm.v2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<assemblyIdentity version="1.0.0.0" name="MyApplication.app" />
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
</requestedPrivileges>
<applicationRequestMinimum>
<defaultAssemblyRequest permissionSetReference="Custom" />
<PermissionSet class="System.Security.PermissionSet" version="1" ID="Custom" SameSite="site" Unrestricted="true" />
</applicationRequestMinimum>
</security>
</trustInfo>
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application />
</compatibility>
</asmv1:assembly>
编辑:
因此,经过几次尝试,模仿似乎有效,但我无法作为主机的网络服务进行身份验证。 应用程序池如何在网络服务下运行?
运用
LOGON32_LOGON_SERVICE
结果是:
Unhandled Exception: System.ComponentModel.Win32Exception: Access is denied
at Tools.Network.Impersonator.Impersonate(String userName, String domainName,
String password, LogonType logonType, LogonProvider logonProvider)
at Tools.Network.Impersonator..ctor(String userName, String domainName, Strin
g password, LogonType logonType, LogonProvider logonProvider)
at Impersonation.Program.Main(String[] args)
运用
LOGON32_LOGON_NEW_CREDENTIALS
结果是:
System.IO.IOException: Logon failure: unknown user name or bad password.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.File.InternalCopy(String sourceFileName, String destFileName, Bo
olean overwrite)
at System.IO.File.Copy(String sourceFileName, String destFileName, Boolean ov
erwrite)
at Impersonation.Program.Main(String[] args)
困惑。
最后! 我找到了答案:
和
http://geek.hubkey.com/2008/02/impersonating-built-in-service-account.html
在Windows 8上。“Microsoft已在Windows 8 / Windows Server 2012中更改了此默认行为。要允许交互式服务,您需要找到注册表项HKEY_LOCAL_MACHINE \\ SYSTEM \\ CurrentControlSet \\ Control \\ Windows并将NoInteractiveServices从1更改为0 “。
这是一个非常好的链接,有代码和我认为这是你可能正在寻找的一切。 如果这个链接有效,请告诉我
.NET(C#)使用网络凭据进行模拟适用于LOGON32_LOGON_NEW_CREDENTIALS作为登录类型,这要求您选择LOGON32_PROVIDER_WINNT50作为登录提供程序类型。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.