- Using Web User Interface - Through Central Administration
- Using STSADM
- Using PowerShell
- Using Object Model
- By .Net code
- By PowerShell
Using Web User Interface:
Where to Look? Go to Central Administration > Application Management > Configure Quotas and Locks >Select Site collection >Select lock status option
Where to Look? Go to Central Administration > Application Management > Configure Quotas and Locks >Select Site collection >Select lock status option
STSADM:
To set Lock:
stsadm -o setsitelock -url <Site-collection-url> -lock <Lock-Type>
To Check current locks applied:
stsadm -o getsitelock -url <Site-collection-url>
Where <Lock-Type> can take one of the following value:
- none - Removes all the locks
- noadditions - Prevents from Addition
- readonly - Can't add/Update/Delete content
- noaccess - You can't view the site at all
PowerShell:
Set-SPSite -Identity <Site-collection-url> -LockState <Lock-State>
Where: <Lock-State> can be:
Set-SPSite -Identity <Site-collection-url> -LockState <Lock-State>
Where: <Lock-State> can be:
- ReadOnly
- Unlock
- NoAdditions
- NoAccess
Ex.
$site = Get-SPSite -Identity <site url>
$site.readonly = $false
$site.readonly = $false
Object Model:
You can Programmatically set the Lock status using SPSite object's Properties:
You can Programmatically set the Lock status using SPSite object's Properties:
- SPSite.ReadLocked
- SPSite.WriteLocked
- SPSite.ReadOnly
Code Sample :
using (SPSite site = new SPSite("http://spserver2:3030"))
{
using (SPWeb sharePointWeb = site.RootWeb)
{
site.AllowUnsafeUpdates = true;
sharePointWeb.AllowUnsafeUpdates = true;
site.ReadOnly = true;
site.LockIssue = "Tesing Lock";
site.AllowUnsafeUpdates = false;
sharePointWeb.AllowUnsafeUpdates = false;
}
}
No comments:
Post a Comment