/// <summary> /// 创建新的模拟环境。 /// 注意采用using(ImpersonateUserHelper helper = ImpersonateUserHelper.NewImpersonateUserHelper()){}方式调用,以确保用完马上释放资源。 /// </summary> /// <returns></returns> public static ImpersonateUserHelper NewImpersonateUserHelper() { string accountName = ConfigUtility.GetFrameworkConfigValue("ImpersonateUserAccount", "配置用户模拟所用的帐号"); string password = ConfigUtility.GetFrameworkConfigValue("ImpersonateUserPassword", "配置用户模拟所用帐号的密码"); string domain = ConfigUtility.GetFrameworkConfigValue("ImpersonateUserDomain", "用户模拟所用的帐号的域"); var helper = new ImpersonateUserHelper(accountName, password, domain); return(helper); }
/// <summary> /// 获取基于当前AD配置用户模拟的账户对象 /// </summary> /// <returns></returns> public static ImpersonateUserHelper GetDomainImpersonateUser() { return(ImpersonateUserHelper.NewImpersonateUserHelper(DomainConfiguration.LDAPAdminAccount, DomainConfiguration.LDAPAdminPassword, DomainConfiguration.LDAPDomainPrefixName)); }
/// <summary> /// 创建新的模拟环境。 /// 注意采用using(ImpersonateUserHelper helper = ImpersonateUserHelper.NewImpersonateUserHelper()){}方式调用,以确保用完马上释放资源。 /// </summary> /// <param name="accountName"></param> /// <param name="password"></param> /// <param name="domain"></param> /// <returns></returns> public static ImpersonateUserHelper NewImpersonateUserHelper(string accountName, string password, string domain) { var helper = new ImpersonateUserHelper(accountName, password, domain); return(helper); }