在自已的程序中操作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: { |
产生该问题的主要原因是moss的默认安全级别不允许第三方去操作
解决办法:修改sharepoint目录下的web.config文件(默认安装路径为C:/Inetpub/wwwroot/wss/VirtualDirectories/80)
将其中的<trust level="WSS_Minimal" originUrl="" />
修改为<trust level="Full" originUrl="" />即可。
如果没有修改这个配置,则使用SPCAMLEditor1.1工具时,也无法正常使用。
相关文章推荐
- eclipse的hadoop插件对集群操作提示org.apache.hadoop.security.AccessControlException:Permission denied
- NET制作安装程序的错误提示:在初始化安装时发生异常 System.IO.FileNotFoundException
- IIS提示“异常详细信息: System.Runtime.InteropServices.ExternalException: 无法执行程序”
- 开发微信发红包时,本地测试没有问题发布IIS上提示 System.Security.Cryptography.CryptographicException: 系统找不到指定的文件。
- 使用MS的Ent Lib(企业库)开发时,提示“System.Security.SecurityException: 不允许所请求的注册表访问权”--转载自蝈蝈俊
- System.Security.Cryptography.CryptographicException: 指定了无效的提供程序类型
- WebApi 数据保护操作未成功。这可能是由于未为当前线程的用户上下文加载用户配置文件导致的。当线程执行模拟时,可能会出现此情况。","ExceptionType":"System.Security.Cryptography.CryptographicException","StackTrace
- 重新想象 Windows 8 Store Apps (70) - 其它: 文件压缩和解压缩, 与 Windows 商店相关的操作, app 与 web, 几个 Core 的应用, 页面的生命周期和程序的生命周期
- ,“计算机”图标上面右键,选择“管理”选项时提示:“该文件没有与之关联的程序来执行该操作
- SQL server 2000安装时提示我”以前的某个程序安装已在安装计算机上创建挂起的文件操作....”
- 【未解决】System.InvalidOperationException: 未在本地计算机上注册“Microsoft.Jet.OLEDB.4.0”提供程序。
- Spring 的优秀工具类盘点,文件资源操作和 Web 相关工具类
- 在“安装”阶段发生异常。 System.Security.SecurityException: 未找到源,但未能
- MFC调不出运行程序,调试是提示“unhandle exception****(0xc0000005)”
- Spring 的优秀工具类盘点,第 1 部分: 文件资源操作和 Web 相关工具类
- .NET相关操作其他文件的小程序(系列文章)
- : 尝试加载 Oracle 客户端库时引发 BadImageFormatException。如果在安装 32 位 Oracle 客户端组件的情况下以 64 位模式运行,将出现此问题。 ---> System.BadImageFormatException: 试图加载格式不正确的程序。
- Spring 的优秀工具类盘点,第 1 部分: 文件资源操作和 Web 相关工具类
- (转)Spring 的优秀工具类盘点,第 1 部分: 文件资源操作和 Web 相关工具类
- System.InvalidOperationException: 未在本地计算机上注册“Microsoft.ACE.OLEDB.12.0”提供程序。