如何将管理员凭据传递给Windows身份

编程入门 行业动态 更新时间:2024-10-26 12:31:38
本文介绍了如何将管理员凭据传递给Windows身份的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

大家好, 我想以编程方式传递管理员用户凭据(VB). 有我的Web应用程序,我以简单用户身份登录了应用程序,但是当我访问计划的任务时,当时我想要应用程序应以编程方式获取凭据,然后将其硬编码为代码. 当前代码如下:

Hi All, I want to pass admin user credentials programatically(VB). there is my web application, i logged-in application as simple user but when i access scheduled tasks that time i want to application should take credentials programatically which i will hard coded into the code. present code is as below:

Dim wi As WindowsIdentity = HttpContext.Current.User.Identity Dim wic As WindowsImpersonationContext = wi.Impersonate()

此处wi对象应包含管理员凭据. 有可能吗? 感谢您的帮助.

here at wi object should contains admin credentials. is it possible? Your help is appreciated.

推荐答案

看看这篇文章,它为您提供了模仿者"类 用于模仿用户的小型C#类 [ ^ ] 您可以包装在using块中,以清楚地了解在特权提升下正在执行哪部分代码.这是非常好的. Have a look at this article, which gives you an ''Impersonator'' class A small C# Class for impersonating a User[^] It''s quite nice that you can wrap in a using block for obvious clarity about which section of code is executing under elevated priviliges.

更多推荐

如何将管理员凭据传递给Windows身份

本文发布于:2023-11-17 05:56:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1609069.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:凭据   如何将   管理员   身份   Windows

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!