尝试列出特定文件夹中的目录和文件。此文件夹将取决于当前用户(Page.User),它由Windows身份验证(NTLM)登录并从Active Directory(homedirectory
属性)中检索。访问被拒绝冒充当前用户访问网络文件夹
我正在使用域用户访问AD并检索文件夹位置,这工作正常。
失败的是使用System.IO.DirectoryInfo.GetDirectories()
检索子文件夹,即使使用模拟。
下面是我使用模拟代码:
System.Security.Principal.WindowsImpersonationContext impersonationContext;
impersonationContext = ((System.Security.Principal.WindowsIdentity)User.Identity).Impersonate();
我已经检查了正在模拟用户访问该文件夹。
从我发现迄今为止,似乎我需要设置委派或Kerberos身份验证,这是真的吗?这是实现这一目标的唯一途径吗?不应该冒充足够的?
你是否检查了此Stackoverflow上一篇文章..? http://stackoverflow.com/questions/2563724/accessing-password-protected-network-drives-in-windows-in-c/2563809#2563809 – MethodMan