冒充者另一个用户身份执行代码。有关更多信息,请查看这些关于和旧博文。安装Impersonator包可从。要安装Impersonator,请在运行以下命令:安装包XperiCode.Impersonator。

用法


using (new Impersonator(@"domainname username", "password")) {

    // this code is executed as the user with supplied credentials.

    var files = Directory.GetFiles(@"server share folder");

}