标签:sharepoint
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.DirectoryServices;
using System.Collections;
namespace ResetIISApplicationIdentity
{
class Program
{
static void Main(string[] args)
{
string[] strusers = System.IO.File.ReadAllLines("userid.txt", System.Text.Encoding.UTF8);
int sid = 0;
foreach (string struser in strusers)
{
string[] arruser = struser.Split(‘|‘);
string name = arruser[0];
string pwd = arruser[1];
DirectoryEntry appPool = new DirectoryEntry("IIS://localhost/W3SVC/AppPools");
try
{
foreach (DirectoryEntry getdir in appPool.Children)
{
if (getdir.Name != "OfficeServerApplicationPool")
{
getdir.Properties["WAMUserName"][0] = name;
getdir.Properties["WAMUserPass"][0] = pwd;
//getdir.Properties["AppPoolIdentityType"][0] = "3"; //"3"应用程序池作为特定用户帐户来运行,"0"应用程序池作为 LocalSystem 来运行,"1"应用程序池作为 LocalService 来运行,"2"应用程序池作为 NetworkService 来运行。
getdir.CommitChanges();
Console.WriteLine(getdir.Name + "\t" + getdir.Properties["WAMUserName"][0] + "\t" + getdir.Properties["WAMUserPass"][0]);
}
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
return;
}
Console.ReadKey();
}
}
}
}
本文出自 “博深” 博客,转载请与作者联系!
修改本机iis中所有application pool的identity(OfficeServerApplicationPool除外) c#
标签:sharepoint
原文地址:http://pclzr.blog.51cto.com/30415/1909733