PowerShell - 具有独特权限的新 SPWeb

发布于 2024-10-16 00:12:27 字数 453 浏览 1 评论 0原文

我想使用 PowerShell 创建一个新的 SPWeb。 我的代码创建网站并将组添加到网站,但不添加用户“TestUser1”。 test\testuser1不属于TestGroup1并获得独立权限。

 $web = New-spweb http://http:/mysharepointurl/site/web -Template "STS#0" -UniquePermissions 

$user = $web.EnsureUser('test\testuser4')

$web.Users.AddUser($user, "Full") #Not working, Add a existing User

$newGroup = $web.SiteGroups["TestGroup6"] #Working, Add a existing Group
$web.Roles["Full"].AddGroup($newGroup)

I want to create a new SPWeb with PowerShell.
My code creates the site and add the group to the site but not the user "TestUser1".
The test\testuser1 belongs not to the TestGroup1 and get intepend permissions.

 $web = New-spweb http://http:/mysharepointurl/site/web -Template "STS#0" -UniquePermissions 

$user = $web.EnsureUser('test\testuser4')

$web.Users.AddUser($user, "Full") #Not working, Add a existing User

$newGroup = $web.SiteGroups["TestGroup6"] #Working, Add a existing Group
$web.Roles["Full"].AddGroup($newGroup)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

落墨 2024-10-23 00:12:27

您是否尝试过

$web.Users.Add -或- $web.AllUsers.Add

public void Add(
    string loginName,
    string email,
    string name,
    string notes
)

http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spusercollection.add.aspx

Have you tried

$web.Users.Add -or- $web.AllUsers.Add

public void Add(
    string loginName,
    string email,
    string name,
    string notes
)

http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spusercollection.add.aspx

慢慢从新开始 2024-10-23 00:12:27

您正在使用 New-SPWeb,因此这意味着您需要将用户添加到 SPWeb

$web.SiteUsers 是网站集组

http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spweb.siteusers.aspx

您应该使用

$web.Users

http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spweb.users.aspx

You are using New-SPWeb, so that means you need to be adding users to the SPWeb.

$web.SiteUsers is the site collection group

http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spweb.siteusers.aspx

You should use

$web.Users

http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spweb.users.aspx

扬花落满肩 2024-10-23 00:12:27

我的工作解决方案:

$web = Get-SPWeb "http://http:/mysharepointurl/site/web" 
$user = $web.AllUsers["test\testuser1"]
$roledef = $web.RoleDefinitions["Vollzugriff"]
$roleass = New-Object Microsoft.SharePoint.SPRoleAssignment($user)
$roleass.RoleDefinitionBindings.Add($roledef)
$web.RoleAssignments.Add($roleass)
$web.Update()

感谢支持!

My working solution:

$web = Get-SPWeb "http://http:/mysharepointurl/site/web" 
$user = $web.AllUsers["test\testuser1"]
$roledef = $web.RoleDefinitions["Vollzugriff"]
$roleass = New-Object Microsoft.SharePoint.SPRoleAssignment($user)
$roleass.RoleDefinitionBindings.Add($roledef)
$web.RoleAssignments.Add($roleass)
$web.Update()

Thanks for the support!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文