您的位置:首页 > 其它

在自已的程序中操作moss相关资源时提示System.Security.SecurityException

2008-07-03 11:29 246 查看
void CreateDocLib()

{

SPWeb _web = new SPSite("http://ianzhang/docs").OpenWeb();

//允许不安全的更新

_web.AllowUnsafeUpdates = true;

_web.AllowUnsafeUpdates = true;

//添加Demo文档库

_web.Lists.Add("Demo3", "Demo", SPListTemplateType.DocumentLibrary);

this.Label1.Text = _web.Lists["Demo3"].ID.ToString();

}

错语信息:

body {font-family:"Verdana";font-weight:normal;font-size: .7em;color:black;}
p {font-family:"Verdana";font-weight:normal;color:black;margin-top: -5px}
b {font-family:"Verdana";font-weight:bold;color:black;margin-top: -5px}
H1 { font-family:"Verdana";font-weight:normal;font-size:18pt;color:red }
H2 { font-family:"Verdana";font-weight:normal;font-size:14pt;color:maroon }
pre {font-family:"Lucida Console";font-size: .9em}
.marker {font-weight: bold; color: black;text-decoration: none;}
.version {color: gray;}
.error {margin-bottom: 10px;}
.expandable { text-decoration:underline; font-weight:bold; color:navy; cursor:hand; }

安全性异常

说明: 应用程序试图执行安全策略不允许的操作。要授予此应用程序所需的权限,请与系统管理员联系,或在配置文件中更改该应用程序的信任级别。 异常详细信息: System.Security.SecurityException: 请求“Microsoft.SharePoint.Security.SharePointPermission, Microsoft.SharePoint.Security, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c”类型的权限已失败。 源错误:
[code]
行 33:             this.Label1.Text = _web.Lists["Demo3"].ID.ToString(); 行 34:         } 行 35:  行 36:         static string GetViewXml() 行 37:         {

[/code]
产生该问题的主要原因是moss的默认安全级别不允许第三方去操作

解决办法:修改sharepoint目录下的web.config文件(默认安装路径为C:/Inetpub/wwwroot/wss/VirtualDirectories/80)

将其中的<trust level="WSS_Minimal" originUrl="" />
修改为<trust level="Full" originUrl="" />即可。

如果没有修改这个配置,则使用SPCAMLEditor1.1工具时,也无法正常使用。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐