最近拍的照片
日期:2009-07-28 | 作者: Allen1. 1号线惊险福娃摸样的奥特曼遮阳面罩。

2. 7月21日,日全食的前一天,空中一朵发亮的云。7月22日,日全食,下雨……

3. 昨日,楼下餐厅失火,索性无人员伤亡(貌似),即日起,开始向园区外觅食。

Allen Le's Blog
1. 1号线惊险福娃摸样的奥特曼遮阳面罩。

2. 7月21日,日全食的前一天,空中一朵发亮的云。7月22日,日全食,下雨……

3. 昨日,楼下餐厅失火,索性无人员伤亡(貌似),即日起,开始向园区外觅食。

twitter、饭否、嘀咕、叽歪,一个一个接连倒下,堪称行为艺术。说明某些商业模式是无法在贵国开展的,互联网在贵国如此脆弱,仿佛就不应该存在,或者只是为了某些目的存在,比如制造民意,制造“网民”世界第一的假象。
叽歪把自己藏起来了,你还能找到TA吗?甚至昨天我还在叽歪注册了账号,想把博客的嘀咕换成叽歪。还没有等换上,就挂了,微博客,你猜中的开始,却没有猜中结局……
图为叽歪挂了之后的截图,下方的名人名言颇为有趣,是来自美国五星上将道格拉斯·麦克阿瑟的演讲《老兵不死》。
Old soldiers never die, they just fade away – General Douglas MacArhur
老兵永远不死,他只是凋零 – 五星上将道格拉斯·麦克阿瑟

IBM星球、微软银河系、星巴克星球,内裤要印上OK字样。让这些东西证明自己还存在。我证明了物质是存在的,假如我的本子被毁了,我是不是一下子回到解放前?
我们看电视,看杂志,看那些百万富翁,看相亲节目,相信有一天能和他们一样,却忘了自己真正要做的事情。我不是说要像电影里面一样组织一支军队!我们是否有勇气像电车男一样挥出自己的天马流星拳?是否有勇气像陈老师和阿娇老师那样直面人生的惨淡?狠狠的揍自己一顿!让自己感到痛……哦!等等,我自己来就可以了,不用牢您驾,谢谢!
好了我关闭Microsoft操作系统,合上DELL电脑,穿上Converse布鞋,准备出门了。
出门前我附上该影片的WARNING,顺便说一下,该片最后出现的那个蛋蛋,据说是Brad Pitt的,我也没考证过是真是假,欢迎有志男女青年考察,以正视听。
WARNING
If you are reading this then this warning is for you.
Every word you read of this useless fine print is another second off you life.
Do not you have other thing to do?
Is your life so empty that you honestly can’t think of a better way to spend these moments?
Or are you so impressed with authority that you give respect and credence to all who claim it?Do you read everything you are supposed read?
Do you think everything you are supposed think?
Buy what you are told you should want?
Get out of your apartment. Meet a member of the opposite sex.
Stop the excessive shopping and masturbation.
Quit your job. Start a fight. Prove you are alive.
If you do not claim your humanity you will become a statistic.
You have been warned……
Tyler.警告
如果你正在阅读本文。那么这次警告正是为你准备的。
你所读到的本文中的每个词都是你生命中又一秒钟的浪费。
你没有别的事情可以做吗?
你的生命真的如此空虚以至于你怎么都想不出另一个打发时间的方法吗?
还是你如此容易受权威的影响以至于你要呈上它所要求的一切尊敬和信任?
你读了所有你被假定应该读的了吗?
你思考了所有你被假定应该思考的了吗?
买了所有你被告知你应当想要的了吗?
离开你的房间。去见一个异性。停止过度的购物和自慰。
辞了你的工作。开始一次搏击。证明你是活着的。
如果你不主张你的人性。你将只是一个统计值。
你已经被警告了……
Tyler.
最怕把一句话翻来倒去的去找中心思想的人,也怕把一些语录当人生信条的人。所以看过拉到,米扫啦扫。
话糙理不糙
娱乐
两性
社会
世界
思想
既然这部片子能表现的如此“形散而意不散”,那么我也就随意记下点我记得的。
最后那个蒙面男请求蓝色暴露狂干掉他,因为蒙面男要告诉所有人事情的真相,但是蓝色暴露狂不让,介于蓝色暴露狂有着神一般的能力,蒙面男只求一死。这个让我想到最近的饭否,好了,it’s a joke。
原文:WMI Functions from ASP.NET
作者:JeroenMX
本文介绍了ASP.NET如何通过WMI创建站点、添加虚拟目录和添加主机头。并且已在Windows Server 2003及IIS6的环境下测试通过。
这玩意儿花了老子3天时间才搞定,用了几个小时写代码,而且当中还花了不少时间解决Win32: Access denied error的问题。当然我要指出的是,无论NETWORK SERVER帐户还是IUSR_<servername>帐户都不要设置过大的权限。对于WMI和IIS metabase的安全机理,我还是一无所知的。我只不过解决问题而已。
首先要从Internet信息服务(IIS)管理器中获取网站标识符,点击“网站”根节点,右侧“标识符”显示的就是网站的ID。默认网站的标识符通常是1。
获取网站标识的功能,我们要用到一个namespace,代码如下:
using System.Management;
下文所有’ServerName’都表示你的服务器名称,或者如果你的代码是本地运行的,也可以用一个点来表示。
创建一个站点,你会用到如下函数。这个函数返回新网站的ID,这样你可以进一步对这个网站进行操作。
public static string CreateWebsite(string serverName, string appPoolName, string ip, string pathToRoot, string hostName, string domainName, int port)
{
ConnectionOptions options = new ConnectionOptions();
options.Authentication = AuthenticationLevel.Connect;
options.EnablePrivileges = true;
options.Impersonation = ImpersonationLevel.Impersonate;
ManagementScope scope = new ManagementScope(string.Format(@\\{0}\root\MicrosoftIISv2, serverName), options);
scope.Connect();
ManagementObject oW3SVC = new ManagementObject(scope,
new ManagementPath(@"IIsWebService='W3SVC'"), null);
ManagementBaseObject[] serverBindings = new ManagementBaseObject[1];
serverBindings[0] = CreateServerBinding(scope, string.Format("{0}.{1}", hostName, domainName), ip, port);
ManagementBaseObject inputParameters = oW3SVC.GetMethodParameters("CreateNewSite");
inputParameters["ServerComment"] = string.Format("{0}.{1}", hostName, domainName);
inputParameters["ServerBindings"] = serverBindings;
inputParameters["PathOfRootVirtualDir"] = pathToRoot;
ManagementBaseObject outParameter = oW3SVC.InvokeMethod("CreateNewSite", inputParameters, null);
string siteId = Convert.ToString(outParameter.Properties["ReturnValue"].Value).Replace("IIsWebServer='W3SVC/", "").Replace("'", "");
ManagementObject oWebVirtDir = new ManagementObject(scope,new ManagementPath(string.Format(@"IIsWebVirtualDirSetting.Name='W3SVC/{0}/root'", siteId)), null);
oWebVirtDir.Properties["AppFriendlyName"].Value = string.Format("{0}.{1}", hostName, domainName);
oWebVirtDir.Properties["AccessRead"].Value = true;
oWebVirtDir.Properties["AuthFlags"].Value = 5; // Integrated Windows Auth.
oWebVirtDir.Properties["AccessScript"].Value = true;
oWebVirtDir.Properties["AuthAnonymous"].Value = true;
oWebVirtDir.Properties["AppPoolId"].Value = appPoolName;
oWebVirtDir.Put();
ManagementObject site = new ManagementObject(scope, new ManagementPath(Convert.ToString(outParameter.Properties["ReturnValue"].Value)), null);
site.InvokeMethod("Start", null);
return siteId;
}
创建一个虚拟目录:
public static void AddVirtualFolder(string serverName, string websiteId,string name, string path){
ManagementScope scope = new ManagementScope(string.Format(@"\\{0}\root\MicrosoftIISV2", serverName));
scope.Connect();
string siteName = string.Format("W3SVC/{0}/Root/{1}", websiteId, name);
ManagementClass mc = new ManagementClass(scope,new ManagementPath("IIsWebVirtualDirSetting"), null);
ManagementObject oWebVirtDir = mc.CreateInstance();
oWebVirtDir.Properties["Name"].Value = siteName;
oWebVirtDir.Properties["Path"].Value = path;
oWebVirtDir.Properties["AuthFlags"].Value = 5; // Integrated Windows Auth.
oWebVirtDir.Properties["EnableDefaultDoc"].Value = true;
// date, time, size, extension, longdate ;
oWebVirtDir.Properties["DirBrowseFlags"].Value = 0x4000003E;
oWebVirtDir.Properties["AccessFlags"].Value = 513; // read script
oWebVirtDir.Put();
ManagementObject mo = new ManagementObject(scope, new System.Management.ManagementPath("IIsWebVirtualDir='" + siteName + "'"), null);
ManagementBaseObject inputParameters = mo.GetMethodParameters("AppCreate2");
inputParameters["AppMode"] = 2;
mo.InvokeMethod("AppCreate2", inputParameters, null);
mo = new ManagementObject(scope, new System.Management.ManagementPath("IIsWebVirtualDirSetting='" + siteName + "'"), null);
mo.Properties["AppFriendlyName"].Value = name;
mo.Put();
}
给网站添加一个主机头:
public static void AddHostHeader(string serverName, string hostHeader, string ip, int port, string websiteID){
ManagementScope scope = new ManagementScope(string.Format(@"\\{0}\root\MicrosoftIISV2", serverName));
scope.Connect();
string siteName = string.Format("'W3SVC/{0}'", websiteID);
ManagementObject mo = new ManagementObject(scope, new System.Management.ManagementPath("IIsWebServerSetting=" + siteName), null);
ManagementBaseObject[] websiteBindings = (ManagementBaseObject[])mo.Properties["ServerBindings"].Value;
ManagementObject mco = CreateServerBinding(scope, hostHeader, ip, port);
ManagementBaseObject[] newWebsiteBindings = new ManagementBaseObject[websiteBindings.Length+1];
websiteBindings.CopyTo(newWebsiteBindings, 0);
newWebsiteBindings[newWebsiteBindings.Length - 1] = mco;
mo.Properties["ServerBindings"].Value = newWebsiteBindings;
mo.Put();
}
最后别忘了这个函数,它可以为网站绑定一个网络标识。
</pre>
<pre>private static ManagementObject CreateServerBinding(ManagementScope scope,string hostName, string ip, int port)
{
ManagementClass mc = new ManagementClass(scope, new ManagementPath("ServerBinding"), null);
ManagementObject mco = mc.CreateInstance();
mco.Properties["Hostname"].Value = hostName;
mco.Properties["IP"].Value = ip;
mco.Properties["Port"].Value = port;
mco.Put();
return mco;
}
安全。如果之用上面的那坨代码还不行。我千方百计想让其运行,但貌似忽视了2件事情。访问WMI和IIS metabase。 ASP.NET在Windows Server 2003和IIS6.0上运行默认使用的是NETWORK SERVICE帐户。但是,我们还是要使用客户端模拟。 所以在Web.config中添加下面一个配置:
<identity impersonate="true" />
使用了这个配置,IUSR_<servername>会使用客户端模拟的方式去访问IIS metabase。在后面的文章里,我就用IUSR_来表示这个帐户。不要忘记,在IUSR_后面加上你的服务器名称才是这个帐户的名字。
WMI权限设置
IIS metabase权限设置
有了足够的权限就能运行了。
如果有高人能对这个方法谈谈自己的感想,并且能指出更好的配置IIS和WMI的方法,那就更赞了。记得之前,我都是自己捣鼓出来的,所以我不知道这个方法是不是最佳的方案。
如果你在运行代码的时候碰到任何问题,我愿意效劳。
译者注:
网上能搜索到的还有一种方法:使用DirectoryEntry方法,方法差不多,关键是要把权限设置好。