SharePoint 2010:使用 ECMAScript 打破角色继承
有谁知道如何使用 ECMAscript 打破网络上的角色继承(即停止从其父级继承权限)?
这是我尝试使用的 JavaScript 代码,但出现运行时错误,指出属性尚未正确初始化:
var clientContext = new SP.ClientContext.get_current();
var web = clientContext.get_web();
clientContext.load(web);
if (!web.get_hasUniqueRoleAssignments()) {
web.breakRoleInheritance(true, false);
}
有趣的是,如果我在调试期间询问 Web 对象,我可以看到 hasUniqueRoleAssignments 属性和 breakRoleInheritance 函数DO 事实上存在。此外,MSDN 声明这两个成员都可以在 SP.SecurableObject class —— 我假设 Web 或 List 都会继承自此类。
有什么想法吗?
Does anybody know how to break role inheritance on a web (i.e. stop inheriting permissions from its parent) using ECMAscript?
This is the JavaScript code that I am trying to use, but I get a runtime error stating that the properties have not been properly initialised:
var clientContext = new SP.ClientContext.get_current();
var web = clientContext.get_web();
clientContext.load(web);
if (!web.get_hasUniqueRoleAssignments()) {
web.breakRoleInheritance(true, false);
}
Interestingly, if I interogate the web object during debugging, I can see that both the hasUniqueRoleAssignments property and breakRoleInheritance function DO in fact exist. In addition, MSDN states that both these members are available on the SP.SecurableObject class -- I would've assumed that both a Web or List would inherit from this class.
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
根据检索客户端对象不会检索所有属性,您将需要调用executeQueryAsync并在委托函数内使用get_hasUniqueRoleAssignments:
According to Retrieving a Client Object Does Not Retrieve All Properties, you will need to call executeQueryAsync and use get_hasUniqueRoleAssignments inside a delegate function: