Managing Users and Groups in .NET

Maker QR Code in .NET Managing Users and Groups

Managing Users and Groups
Recognize QR Code In Visual Studio .NET
Using Barcode Control SDK for Visual Studio .NET Control to generate, create, read, scan barcode image in .NET applications.
QR Code Generator In Visual Studio .NET
Using Barcode generation for VS .NET Control to generate, create QR Code JIS X 0510 image in .NET framework applications.
MicrosoftSharePointSPUser, respectively You can use the Get-SPUser cmdlet
QR Code 2d Barcode Recognizer In .NET
Using Barcode recognizer for Visual Studio .NET Control to read, scan read, scan image in Visual Studio .NET applications.
Paint Bar Code In VS .NET
Using Barcode printer for Visual Studio .NET Control to generate, create bar code image in VS .NET applications.
to obtain the values to be passed to the method The following example demonstrates how to add a new group to a site collection
Decoding Bar Code In VS .NET
Using Barcode reader for VS .NET Control to read, scan read, scan image in .NET framework applications.
Encode QR Code ISO/IEC18004 In Visual C#.NET
Using Barcode creation for VS .NET Control to generate, create Denso QR Bar Code image in .NET framework applications.
PS PS >> PS > $owner = Get-SPUser -Web http://nimaintranet -Identity POWERSHELL\maka > $defaultUser = Get-SPUser -Web http://nimaintranet -Identity POWERSHELL\nigo > $spGroupCollectionAdd("New Group",$owner,$defaultUser,"Group Description")
Make QR Code JIS X 0510 In Visual Studio .NET
Using Barcode printer for ASP.NET Control to generate, create QR Code image in ASP.NET applications.
Paint Denso QR Bar Code In Visual Basic .NET
Using Barcode creator for Visual Studio .NET Control to generate, create QR image in .NET applications.
If the users do not exist in the site, the Get-SPUser command will fail You can add a user to a site using the New-SPUser cmdlet, as described later in this chapter Alternatively, you can use the EnsureUser method to add a user to the sites User Info list, as demonstrated here:
Encode GS1 DataBar Stacked In VS .NET
Using Barcode printer for .NET Control to generate, create GS1 DataBar image in .NET applications.
Barcode Printer In Visual Studio .NET
Using Barcode generation for .NET Control to generate, create bar code image in .NET applications.
PS > $spWebEnsureUser("powershell\nigo")
Generating Code 128 Code Set A In .NET Framework
Using Barcode encoder for .NET framework Control to generate, create Code 128 image in .NET applications.
USD - 8 Drawer In Visual Studio .NET
Using Barcode generation for Visual Studio .NET Control to generate, create USD8 image in Visual Studio .NET applications.
Adding groups as shown in this example works only for Web applications that use Windows authentication If the Web application is using claims-based authentication, you can use the following code instead
Code 39 Drawer In .NET
Using Barcode creator for ASP.NET Control to generate, create Code 39 Extended image in ASP.NET applications.
Create Code-128 In Java
Using Barcode creation for Eclipse BIRT Control to generate, create USS Code 128 image in BIRT applications.
PS >> PS >> PS > $owner = Get-SPUser -Web http://nimaintranet -Identity ` (New-SPClaimsPrincipal POWERSHELL\maka -IdentityType WindowsSamAccountName) > $defaultUser = Get-SPUser -Web http://nimaintranet -Identity ` (New-SPClaimsPrincipal POWERSHELL\nigo -IdentityType WindowsSamAccountName) > $spGroupCollectionAdd("New Group",$owner,$defaultUser,"Group Description")
GS1 - 13 Generation In Java
Using Barcode encoder for Java Control to generate, create EAN-13 image in Java applications.
Drawing UCC-128 In Java
Using Barcode printer for BIRT Control to generate, create UCC-128 image in BIRT applications.
The following function, New-SPGroup, automates the task of adding groups
Barcode Decoder In C#.NET
Using Barcode Control SDK for .NET Control to generate, create, read, scan barcode image in .NET framework applications.
Making Data Matrix 2d Barcode In Visual Basic .NET
Using Barcode maker for Visual Studio .NET Control to generate, create Data Matrix image in .NET applications.
function New-SPGroup( [string]$url, [string]$group, [string]$owner, [string]$defaultUser, [string]$description ) { $spWeb = Get-SPWeb $url # Store groups in collection $spGroupCollection = $spWebSiteGroups; # Check if group already exists if ($spGroupCollection[$group]) { Write-Host "The group: $group already exists"; } else { # Check if Web application uses Claims authentication if ($spWebSiteWebApplicationUseClaimsAuthentication) { $owner = (New-SPClaimsPrincipal $owner ` -IdentityType WindowsSamAccountName)ToEncodedString(); $defaultUser = (New-SPClaimsPrincipal $defaultUser ` -IdentityType WindowsSamAccountName)ToEncodedString(); }
Print UCC-128 In None
Using Barcode generator for Online Control to generate, create USS-128 image in Online applications.
Paint USS-128 In None
Using Barcode creator for Software Control to generate, create UCC - 12 image in Software applications.
PowerShell for Microsoft SharePoint 2010 Administrators
# Ensure user if(($spWebEnsureUser($owner)) -and ($spWebEnsureUser($defaultUser))) { $objOwner = Get-SPUser -Web $url -Identity $owner; $objdefaultUser = Get-SPUser -Web $url -Identity $defaultUser; # Create Group $spGroupCollectionAdd($group,$objOwner,$objDefaultUser,$description); } } $spWebDispose() }
To use the New-SPGroup function to add a new group to a site collection, type the following:
PS > New-SPGroup -url http://nimaintranet -group "New Group" ` >> -owner powershell\maka -defaultUser powershell\nigo -description "My Group"
If the group already exists, the function returns Group already exists Otherwise, the group is created in the site collection
Modifying SharePoint Groups
You can also modify existing groups in SharePoint 2010 using Windows PowerShell First, retrieve an existing group from the group collection, as shown here:
PS > $spWeb = Get-SPWeb http://nimaintranet PS > $spGroupCollection = $spWebSiteGroups PS > $spGroup = $spGroupCollection["New Group"]
Since this is a task that might be repeated many times, we wrap the code up in a function named Get-SPGroup
function Get-SPGroup([string]$url, [string]$group) { $spWeb = Get-SPWeb $url $spGroupCollection = $spWebSiteGroups; $spWebDispose() return $spGroupCollection[$group]; }
In this function, we store a group collection in the variable spGroupCollection and return a specific group by using the group name as the index value You can use the function by typing the following:
PS > $spGroup = Get-SPGroup -url http://nimaintranet -group "New Group"
With an instance of a MicrosoftSharePointSPGroup object stored in a variable, we can change the properties of the group The next example demonstrates how to change the group name
PS > $spGroupName = "New Group Name"
19:
Managing Users and Groups
It s also possible to change the value of the Description property However, this property does not surface anywhere in the browser-based user interface What appears in the browser on the groupsaspx page is actually the value of the About Me (with the internal name Notes) field of the corresponding item in the User Info list This is set to the same value as the group s description once when the group is created, but is not changed later if the value of the Description property changes And if a user edits a group s description in the browser, this doesn t change the value of the Description property either The following example demonstrates how to set the value of a group s Description property and set the Notes property of the corresponding item in the User Info list
PS PS >> PS PS > $spGroupDescription = "New Description" > $spGroupListItem = ($spWebLists["User Information List"]Items | Where-Object {$_["Group"] -eq $spGroupName}) > $spGroupListItem["Notes"] = $spGroupDescription > $spGroupListItemUpdate()
To change the owner of the group, you assign to the Owner property an object of type MicrosoftSharePointSPUser, which can be retrieved using the Get-SPUser cmdlet
Copyright © OnBarcode.com . All rights reserved.