SharePoint 常用操作杂谈
2024-08-29 12:17:20
前言
本文完全原创,转载请说明出处,希望对大家有用。
本篇博客是个人总结,一方面以便日后查看,另一方面希望能为其他人提供一些便利。
阅读目录
正文
SharePoint 2010 UserProfile 添加属性
以下方法是为了将自定义属性添加到SharePoint UserProfile中
SPServiceContext context =SPServiceContext.GetContext(site);
UserProfileConfigManager upcm = new UserProfileConfigManager(context);
ProfilePropertyManager ppm = upcm.ProfilePropertyManager;
CorePropertyManager cpm = ppm.GetCoreProperties();
if (cpm.GetPropertyByName(name) == null)
{
CoreProperty cp = cpm.Create(false);
cp.Name = name;
cp.DisplayName = name;
cp.Type = PropertyDataType.StringSingleValue;
cp.Length = ;
cpm.Add(cp);
ProfileTypePropertyManager ptpm =ppm.GetProfileTypeProperties(ProfileType.User);
ProfileTypeProperty ptp = ptpm.Create(cp);
ptpm.Add(ptp);
ProfileSubtypeManager psm =ProfileSubtypeManager.Get(context);
ProfileSubtype ps = psm.GetProfileSubtype(ProfileSubtypeManager.GetDefaultProfileName(ProfileType.User));
ProfileSubtypePropertyManager pspm = ps.Properties;
ProfileSubtypeProperty psp = pspm.Create(ptp);
psp.IsUserEditable = true;
psp.PrivacyPolicy = PrivacyPolicy.OptIn;
psp.DefaultPrivacy = Privacy.Organization;
pspm.Add(psp);
}
如果需要新增的属性是一个Taxonomy类型的字段,则加入以下代码:
TaxonomySession taxonomySession = new TaxonomySession(site);
TermStore termStore = taxonomySession.DefaultSiteCollectionTermStore;
Group group = termStore.Groups[your group name];
TermSet termSet = group.TermSets[your Termset name];
cp.TermSet = termSet;
修改默认母板页
通常我们在发布自定义母板页的同时希望将站点默认模板页修改为自定义母板页
public void changeCustomMasterPage(SPWeb web, string masterpageurl,bool isCustomMasterPage)
{
SPFile newMasterPageFile = web.GetFile(master);
if (newMasterPageFile.Exists)
{
if (isCustomMasterPage)
web.CustomMasterUrl = newMasterPageFile.ServerRelativeUrl;
else
web.MasterUrl = newMasterPageFile.ServerRelativeUrl;
web.Update();
}
}
Taxonomy字段绑定TermSet
public static void BindTermSet(TaxonomyField field, TermSet termSet, bool isPathRendered)
{
try
{
field.SspId = termSet.TermStore.Id;
field.TermSetId = termSet.Id;
field.TargetTemplate = string.Empty;
field.AnchorId = Guid.Empty;
field.IsPathRendered = isPathRendered;
field.Update(true);
}
catch (Exception ex)
{
throw ex;
}
}
Query Author
<Where>
<Eq>
<FieldRef Name="Author" LookupId="True" />
<Value Type="User"></Value>
</Eq>
</Where> <Where>
<Eq>
<FieldRef Name="Author" LookupId="True" />
<Value Type="Lookup"></Value>
</Eq>
</Where> <Where>
<Eq>
<FieldRef Name="Author" />
<Value Type="Integer">
<UserID />
</Value>
</Eq>
</Where>
最新文章
- 运用Mono.Cecil 反射读取.NET程序集元数据
- 使用shell/python获取hostname/fqdn释疑
- iOS项目中常用的第三方开源库
- 小白学数据分析----->;移动游戏的使用时长分析
- 仿APP系列 - 超级强大的拖动插件(支持块级的拖拉,左右拖拉)
- 5月18日:top10面试算法-LRUcache的实现
- Spring事务管理 -- 挺好
- oracle 树形SQL
- Pull解析-解析xml文件
- 原生javascript焦点轮播图
- Apache Hadoop压缩包与Eclipse结合,导入jar包归整总结(手动)
- LA 3998 Prime k-tuple
- Android Handler Message总结一下
- SGU 200. Cracking RSA(高斯消元+高精度)
- NTSC色域(CIE1931)计算公式
- ElasticSearch的Marvel更新license
- 【译】Java中的字符串字面量
- 浅谈移动端适配-rem
- JSON的简单书写(初学),使用Java语言反序列化
- 机器学习——KMeans聚类,KMeans原理,参数详解
热门文章
- max_int和-1
- swift 单例模式
- CXSprite.cpp文件
- Node.js用fs.renameSync报cross-device link not permitted错
- sensor dma alloc failed问题
- hdoj 1272 小希的迷宫 又一个并查集的简单应用
- java学习之局部变量以及全局变量
- Cannot proceed with delivery: an existing transporter instance is currently uploading this package
- 1.thinkphp 权限分析
- MyBatis的优缺点