![](/img/trans.png)
[英]Using ASP.NET to create a windows authenticated token from a basic authenicated web site
[英]Create Windows accounts and set file permissions from ASP.NET site
我正在構建一個ASP.NET應用程序,它將在服務器上創建Windows帳戶和組,並為這些帳戶設置文件/文件夾權限。
我該怎么做?
我已經考慮過使用CACLS.exe,但最終我會陷入其他問題。 .NET框架中還有其他選擇嗎?
我取得類似成就的一種方式。 那是某些操作或過程需要管理特權的地方,而您試圖通過ASP.NET進行此操作的是構建WCF服務應用程序(理想情況下是作為自托管服務)並使其以管理員身份運行。
然后,從ASP.NET應用程序中調用服務中的方法,該方法將起作用。
編輯
這是使控制台應用程序成為WCF自托管應用程序的代碼
class Program
{
static void Main(string[] args)
{
var webServiceHhost = new WebServiceHost(typeof(AppCmdService), new Uri("http://localhost:7654"));
ServiceEndpoint ep = webServiceHhost.AddServiceEndpoint(typeof(AppCmdService), new WebHttpBinding(), "");
var serviceDebugBehavior = webServiceHhost.Description.Behaviors.Find<ServiceDebugBehavior>();
serviceDebugBehavior.HttpHelpPageEnabled = false;
webServiceHhost.Open();
Console.WriteLine("Service is running");
Console.WriteLine("Press enter to quit ");
Console.ReadLine();
webServiceHhost.Close();
}
}
上面的代碼清單中的AppCmdService
類是我的WCF服務類
看來這是我正在尋找的System.DirectoryServices.AccountManagement命名空間 。 我將把它很好地包裝在WCF服務中(感謝Shiv Kumar ),然后從我的應用程序中調用它。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.