如何在打开虚拟目录时模拟不同的用户?
我们有一个 ASP.NET (3.5) 应用程序,它使用表单身份验证来验证帐户。 在登录表单上,我还使用 LogonUser 获取 Windows 登录令牌,我用它来模拟登录用户以浏览私有目录(文件显示在 GridView 中,并且在数据绑定之前模拟用户。)我刚刚了解到我们还需要在虚拟目录中模拟用户。 有没有办法让我在加载虚拟目录之前进行模拟,或者在整个应用程序中进行模拟,而无需切换到 Windows 身份验证?
We have an ASP.NET (3.5) application which uses Forms Authentication to authenticate accounts. On the logon form, I also get a windows login token using LogonUser, which I use to impersonate the logged on user for browsing private directories (the files are displayed in a GridView, and the user is impersonated just before the data is bound.) I just learned that we also need to impersonate the user in a virtual directory. Is there a way for me to impersonate just before the virtual directory is loaded, or across the entire application without switching to Windows Authentication?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您只是执行一项任务(例如访问网络资源),我喜欢使用我为此目的创建的现有 AD 帐户,并在代码中调用它。
我喜欢抽象出这里找到的示例 http://support.microsoft.com/kb/306158,进入辅助类。 这将允许做这样的事情......
If you are just performing a single task (like accessing a network resource) I like to use an existing AD account I create just for such purposes and call it in-code.
I like to abstract out the example found here http://support.microsoft.com/kb/306158, into a helper class. This will allow to do something like this...