.NET FISHER

专注.NET, Sharepoint, MCMS, WinFX, Ajax....
posts - 12, comments - 28, trackbacks - 0, articles - 1

2005年4月16日

在一个Sharepoint的项目中,需要暂时禁止访问一些网站。因此我做了一webservice完成此功能.代码如下:


[WebMethod]
public bool SuspendSite(string virtualServerUrl, string siteRelativeUrl, bool suspend)
{
 
 Microsoft.SharePoint.Administration.SPGlobalAdmin ga = new Microsoft.SharePoint.Administration.SPGlobalAdmin();
 Microsoft.SharePoint.Administration.SPVirtualServer server = ga.OpenVirtualServer(new Uri(virtualServerUrl));

 if(server == null) return false;

 Microsoft.SharePoint.SPSite spSite = server.Sites[relatedUrl];
 spSite.AllowUnsafeUpdates = true;
    
 spSite.WriteLocked = false;
 spSite.ReadLocked = suspend;
 if(suspend)
 {
  spSite.RootWeb.AllowUnsafeUpdates = true;
  spSite.LockIssue = "Unknown";
 }
 spSite.AllowUnsafeUpdates = false;
 spSite.Close();
 spSite.Dispose();
 return true;
}


要注意几点:
1. 网站必须是顶级网站.
2. 不能从 GetContextSite(Context) 或 new SPSite(url) 得到 SPSite, 必须从SPGlobalAdmin中找出此SPSite,因为此为Global Admin中的功能.否则将有Access Denied的错误.(我也不理解为何要如此,估计是Microsoft的愚蠢吧)
3. WebService的App Pool Account必须有足够的权限.

posted @ 2005-04-16 11:30 FISHER 阅读(1282) 评论(1) 编辑

我们在目前的项目中间使用了Sharepoint Portal作为索引引擎去crawling我们的MCMS (Microsoft Content

Management) 网站上的内容。 MCMS上的内容我们用了一些Meta tag.但是我们发现Sharepoint Portal 搜索引擎在索

引这些Meta Data的时候,不能够很好处理日期类型的Meta Data.例如:

在某些网页上,有一些Meta tag如:

<META content="2005-1-1" name="N.eventstartdate">
<META content="2005-1-20" name="N.eventenddate">


当我们用Sharepoint Search Service,并使用类似

"urn:schemas.microsoft.com:htmlinfo:metainfo:DATE" < GetGMTDate()


的Query语句去查询,得不到任何结果。同样,在Sharepoint Portal的Advanced Search中,也得不到任何结果。

Sharepoint Portal的搜索引擎crawling和Indexing网站或网页内容的时候,使用了一种叫IFilter的技术。例如使用

了nthtml.dll作为HTML IFilter处理HTML的内容。但是,nthtml.dll不能够自动转换类似"2005-1-1"的内容到日期

型.所以用日期型去查询讲得不到任何结果.


在微软的Platform SDK中有一个IFilter的例子叫HTMLProp能很好的处理日期类型的Meta tag.用它来替代nthtml.dll将能解决上述搜索的问题.下面是我安装HTMLProp.dll的步骤:


1. 编译HTMLProp.dll的例子 (在Platform SDK中能找到)

2. 拷贝HTMLProp.dll到 C:\Windows\System32.

3. 拷贝HTMLProp.ini到 C:\Windows\System32.

4. 修改HTMLProp.ini为


n.eventstartdate (VT_FILETIME) = d1b5d3f0-c0b3-11cf-9a92-00a0c908dbf1 n.eventstartdate
n.eventenddate (VT_FILETIME) = d1b5d3f0-c0b3-11cf-9a92-00a0c908dbf1 n.eventenddate


5. 停下Microsoft SharepointPS Search Service和正在clawling的Job.

6. 打开Registry,修改 HKLM\SYSTEM\CurrentControlSet\Control\ContentIndex\DLLsToRegister,加入一行 C:\WINDOWS\system32\htmlprop.dll

7. 运行 "regsvr32.exe %windir%\System32\HtmlProp.dll".

8. 找到HKLM\SOFTWARE\Microsoft\SPSSearch\ContentIndexCommon\Filters\Extension\.htm 和 HKLM\SOFTWARE\Microsoft\SPSSearch\ContentIndexCommon\Filters\Extension\.html,把原值 {E0CA5340-4534-11CF-B952-00AA0051FE20} 替换为 {f4309e80-a1db-11d1-a8fb-00e098006ed3}

9. 察看HKLM\SOFTWARE\Microsoft\SPSSearch\ContentIndexCommon\Filters\CLSID\ 下的所有Key, 把值 {E0CA5340-4534-11CF-B952-00AA0051FE20} 全部替换为 {f4309e80-a1db-11d1-a8fb-00e098006ed3}

10. 在 Sharepoint Portal 的 Site Settings 中, 选择 "Manage Properties of Crawled Content", 删除 urn:schemas.microsoft.com:htmlinfo:metainfo:N.eventstartdate 和 urn:schemas.microsoft.com:htmlinfo:metainfo:N.eventenddate。

11. Reset 所有的 Content Indexes.

12. Full update 所有的 Content Indexes.

13. 在 "Manage Properties of Crawled Content"中,打开 urn:schemas.microsoft.com:htmlinfo:metainfo:N.eventstartdate 和 urn:schemas.microsoft.com:htmlinfo:metainfo:N.eventenddate 并选择 "Included in the Advanced Search".

14. 重新 Reset 和 Full update 所有的 Content Indexes.


日期类型的Metadata 就能够很好的工作了.

posted @ 2005-04-16 01:51 FISHER 阅读(989) 评论(0) 编辑