Showing posts with label SharePoint. Show all posts
Showing posts with label SharePoint. Show all posts

Feb 7, 2012

How To Create Groups, Add Users In That Group And Give Permissions

SharePoint site security levels are assigned to Groups/Users. Users are added in different groups and each group is assigned security levels.
Security levels are assigned by the administrator who is adding the user. There are four levels by default.

* 
Full Control - Has full control. 
* 
Design - Can view, add, update, delete, approve, and customize. 
* Contributor - Can add content to existing document libraries and lists.
* 
Read - Can view pages and list items and download documents. 
* 
View Only - Can view pages, list items, and documents. Document types with server-side file handlers can be viewed in the browser but not downloaded. 

To add Groups in SharePoint site follow the following steps:

1. Go to your site and login with administrator. From Site Action choose Site Settings.


2. From Users and Permissions select Site Permissions and from ribbon click on  Create Group.

3. Give a name to user Group and choose the permission level. Click on save button.
 
If you want to change the permission level of existing Group, choose Grant Permissions in Step-2 and follow the following image and choose the permission level.
Add Users In Groups
4. Go to Site Action and Site Settings as in Step-1
5. From Users and Permissions select People and Groups and from left panel choose your Group in which you want to add users.Click on New->Add Users.
6. From pop-up window insert user name and check for existence. If user exists click OK button.
  

Feb 5, 2012

Enable Anonymous Access in SharePoint 2010

When you enable anonymous access to a Web site, you allow anonymous users (and authenticated users who have not been granted access to the site) to browse the entire Web site, including any list, library, folder within a list or library, list item, or document that inherits its permissions from the Web site. If anonymous access has been enabled by the server administrator, members of the Site name Owners SharePoint group can do the following:
· 1. Grant anonymous access on a site.
· 2. Grant anonymous access only on lists and libraries.
· 3. Block anonymous access on a site.
If you want to enable Anonymous Access enable to your site or sub sites, you have to first enable Anonymous Access to your top level site. Sub sites inherit top level permissions or you can change permission settings.
To enable Anonymous Access on your top level site. Here are some points.....
1. Open your Central Administration. From Application Management select Manage Web Applications.
If anonymous access is not enabled you can not check/uncheck Anonymous User Policy from ribbon.


2. Click on Authentication Providers and change the default provider setting by clicking Default Authentication Providers. Edit Authentication and check Enable anonymous access and click save button.
3. Now click on Anonymous Policy from ribbon.


































Now you are able to change the anonymous policy from pop-up window


click on save button to save changes.

4. Now go to your top level share point site . Click on Site Action button and select Site Settings option and from settings page click Site Permissions.



5. Anonymous Access button will be not visible in ribbon. To show Anonymous Access button click Stop Inheriting Permissions.






6. Now from user page ribbon click Anonymous Access button. If Anonymous Access is not enabled from central administration, this is not enabled.











from pop-up window you can give access to anonymous users. Click OK to save changes.





















now the access permission will be displayed in the access list.


7. Now logged out from this site and open again the site. You will see that, it will not ask for login.


Aug 30, 2010

How to add ribbon tabs and subgroups on sharepoint 2010 application page

it is quite easy to add your own Ribbon controls and tabs to existing lists, libraries, and even your own web parts. You can even add contextual ribbon tabs to web parts hosted in your own custom Application Pages.












open VS2010 and create an Empty SharePoint Project.Add a reference to the Microsoft.Web.CommandUI assembly.Now right-clicking the project,choose Add,new item and select Application Page. This will get created as Layouts//.In code behiend file Create the ribbon by declaring two strings that hold the Tab and the GroupTemplate definitions like this:

@"

id=""Ribbon.MyTab""

Title=""Actions""

Description=""This
is a sample tab""

Sequence=""1105"">

Id=""Ribbon.MyTab.Scaling"">

Id=""Ribbon.MyTab.Noting.MaxSize""

GroupId=""Ribbon.MyTab.Noting""

Size=""OneLargeTwoMedium""/>

Id=""Ribbon.MyTab.Noting.Scaling.CustomTabScaling""

GroupId=""Ribbon.MyTab.Noting""

Size=""OneLargeTwoMedium""
/>

Id=""Ribbon.MyTab.Attachments.MaxSize""

GroupId=""Ribbon.MyTab.Attachments""

Size=""OneLargeTwoMedium""/>

Id=""Ribbon.MyTab.Attachments.Scaling.CustomTabScaling""

GroupId=""Ribbon.MyTab.Attachments""

Size=""OneLargeTwoMedium""
/>

Id=""Ribbon.MyTab.Others.MaxSize""

GroupId=""Ribbon.MyTab.Others""

Size=""OneLargeTwoMedium""/>

Id=""Ribbon.MyTab.Others.Scaling.CustomTabScaling""

GroupId=""Ribbon.MyTab.Others""

Size=""OneLargeTwoMedium""
/>


Id=""Ribbon.MyTab.Noting""

Description=""This
is a sample group!""

Title=""Notings""

Sequence=""52""

Template=""Ribbon.Templates.Noting"">

Id=""Ribbon.MyTab.Noting.Controls"">

Id=""Ribbon.MyTab.Noting.NewNoting""

Sequence=""15""

Description=""Opens
a modal dialog box""

Command=""Ribbon.MyTab.Noting.NewNoting.Click""

Image32by32=""/_layouts/images/PPEOPLE.GIF""

LabelText=""New""

TemplateAlias=""cust1""/>

Id=""Ribbon.MyTab.Noting.EditNoting""

Sequence=""17""

Image32by32=""/_layouts/images/PPEOPLE.GIF""

Description=""Simple
alert button""

Command=""Ribbon.MyTab.Noting.EditNoting.Click""

LabelText=""Edit""

TemplateAlias=""cust2""/>

Id=""Ribbon.MyTab.Attachments""

Description=""This
is a sample group!""

Title=""Attachments""

Sequence=""62""

Template=""Ribbon.Templates.Attachments"">

Id=""Ribbon.MyTab.Attachments.Controls"">

Id=""Ribbon.MyTab.Attachments.Enclosers""

Sequence=""25""

Description=""Opens
a modal dialog box""

Command=""Ribbon.MyTab.Attachments.Encloser.Click""

Image32by32=""/_layouts/images/PPEOPLE.GIF""

LabelText=""Encloser""

TemplateAlias=""cust3""/>

Id=""Ribbon.MyTab.Attachments.Files""

Sequence=""27""

Image32by32=""/_layouts/images/PPEOPLE.GIF""

Description=""Simple
alert button""

Command=""Ribbon.MyTab.Attachments.Files.Click""

LabelText=""Files""

TemplateAlias=""cust4""/>

Id=""Ribbon.MyTab.Others""

Description=""This
is a sample group!""

Title=""Others""

Sequence=""72""

Template=""Ribbon.Templates.Others"">

Id=""Ribbon.MyTab.Others.Controls"">

Id=""Ribbon.MyTab.Others.Close""

Sequence=""35""

Description=""Close
File""

Command=""Ribbon.MyTab.Others.CloseFile.Click""

Image32by32=""/_layouts/Images/PPEOPLE.GIF""

LabelText=""Close
File""

TemplateAlias=""cust5""/>

Id=""Ribbon.MyTab.Others.Download""

Sequence=""37""

Image16by16=""/_layouts/FMSPages/Images/zip_16x16.png""

Image32by32=""/_layouts/FMSPages/Images/zip_32x32.png""

Description=""Download
For Print""

Command=""Ribbon.MyTab.Others.Download.Click""

LabelText=""Download""

TemplateAlias=""cust6""/>

";

//
Attachment subgroup

private
string contextualTabTemplateAttachments = @"


Id=""Ribbon.Templates.Attachments"">

Title=""OneLargeTwoMedium""
LayoutTitle=""OneLargeTwoMedium"">


Type=""OneRow"">


DisplayMode=""Large"" TemplateAlias=""cust3"" />


DisplayMode=""Large"" TemplateAlias=""cust4"" />

"

;

//Noting
subgroup

private
string contextualTabTemplateNotings =
@"


Id=""Ribbon.Templates.Noting"">

Title=""OneLargeTwoMedium""
LayoutTitle=""OneLargeTwoMedium"">


Type=""OneRow"">


DisplayMode=""Large"" TemplateAlias=""cust1"" />


DisplayMode=""Large"" TemplateAlias=""cust2"" />

";

//Others
subgroup

private
string contextualTabTemplateOthers =
@"


Id=""Ribbon.Templates.Others"">

Title=""OneLargeTwoMedium""
LayoutTitle=""OneLargeTwoMedium"">


Type=""OneRow"">


DisplayMode=""Large"" TemplateAlias=""cust5"" />


DisplayMode=""Large"" TemplateAlias=""cust6"" />

";



Now add add tabs,groups and their functionality.
The code, though a little long, is actually quite simple and can be reused almost completely for any number of ribbons. The first function simply adds the display of the ribbon while the second registers the JavaScript to call when the respective buttons’ click commands are called.

protected override void OnPreRender(EventArgs e)

{

base.OnPreRender(e);

this.AddRibbonTab();

AddTabEvents();

}

private void AddRibbonTab()

{

// Gets the current instance of the ribbon on the page.

SPRibbon ribbon = SPRibbon.GetCurrent(this.Page);

//Prepares an XmlDocument object used to load the ribbon

XmlDocument ribbonExtensions = new XmlDocument();

//Load the contextual tab XML and register the ribbon.

ribbonExtensions.LoadXml(this.mainTab);

ribbon.RegisterDataExtension(ribbonExtensions.FirstChild, "Ribbon.Tabs._children");

//Load the custom templates and register the ribbon.

ribbonExtensions.LoadXml(this.contextualTabTemplateAttachments);

ribbon.RegisterDataExtension(ribbonExtensions.FirstChild,

"Ribbon.Templates._children");

ribbonExtensions.LoadXml(this.contextualTabTemplateNotings);

ribbon.RegisterDataExtension(ribbonExtensions.FirstChild,

"Ribbon.Templates._children");

ribbonExtensions.LoadXml(this.contextualTabTemplateOthers);

ribbon.RegisterDataExtension(ribbonExtensions.FirstChild,

"Ribbon.Templates._children");

ribbon.Minimized = false;

ribbon.CommandUIVisible = true;

const string initialTabId = "Ribbon.MyTab";

if (!ribbon.IsTabAvailable(initialTabId))

ribbon.MakeTabAvailable(initialTabId);

ribbon.InitialTabId = initialTabId;

}

private void AddTabEvents()

{

var commands = new List<IRibbonCommand>();

// register the command at the ribbon. Include the callback to the server

// to generate the xml

commands.Add(new SPRibbonCommand("Ribbon.MyTab.Noting.NewNoting.Click", "openPopup('AddFileNotings.aspx?','New Noting',650,450);", "true"));

commands.Add(new SPRibbonCommand("Ribbon.MyTab.Noting.EditNoting.Click", "alert('goodbye cruel world');", "true"));

commands.Add(new SPRibbonCommand("Ribbon.MyTab.Attachments.Encloser.Click", "openPopup('AttachEnclosers.aspx?','Attach Encloser',470,250);", "true"));

commands.Add(new SPRibbonCommand("Ribbon.MyTab.Attachments.Files.Click", "openPopup('AttachFiles.aspx?','Attach Files',470,470);", "true"));

commands.Add(new SPRibbonCommand("Ribbon.MyTab.Others.CloseFile.Click", "CloseFile();", "true"));

commands.Add(new SPRibbonCommand("Ribbon.MyTab.Others.Download.Click", "DownloadFiles();", "true"));

//Register initialize function

var manager = new SPRibbonScriptManager();

var methodInfo = typeof(SPRibbonScriptManager).GetMethod("RegisterInitializeFunction", BindingFlags.Instance | BindingFlags.NonPublic);

methodInfo.Invoke(manager, new object[] { Page, "InitPageComponent", "/_layouts/FMSPages/PageComponent.js", false, "FMSPages.PageComponent.initialize()" });

// Register ribbon scripts

manager.RegisterGetCommandsFunction(Page, "getGlobalCommands", commands);

manager.RegisterCommandEnabledFunction(Page, "commandEnabled", commands);

manager.RegisterHandleCommandFunction(Page, "handleCommand", commands);

}



The Ribbon button event handling requires some extra JavaScript as well that is loaded within another .JS file. To do this, simply add a new JavaScript file in your // folder and call it PageComponent.js. This is what it’ll look like.

function ULS_SP() {

if (ULS_SP.caller) {

ULS_SP.caller.ULSTeamName = "Windows SharePoint Services 4";

ULS_SP.caller.ULSFileName = "/_layouts/FMSPages/PageComponent.js";

}

}

Type.registerNamespace('FMSPages');

// RibbonApp Page Component

FMSPages.PageComponent = function () {

ULS_SP();

FMSPages.PageComponent.initializeBase(this);

}

FMSPages.PageComponent.initialize = function () {

ULS_SP();

ExecuteOrDelayUntilScriptLoaded(Function.createDelegate(null,

FMSPages.PageComponent.initializePageComponent), 'SP.Ribbon.js');

}

FMSPages.PageComponent.initializePageComponent = function () {

ULS_SP();

var ribbonPageManager = SP.Ribbon.PageManager.get_instance();

if (null !== ribbonPageManager) {

ribbonPageManager.addPageComponent(FMSPages.PageComponent.instance);

ribbonPageManager.get_focusManager().requestFocusForComponent(

FMSPages.PageComponent.instance);

}

}

FMSPages.PageComponent.refreshRibbonStatus = function () {

SP.Ribbon.PageManager.get_instance().get_commandDispatcher().executeCommand(

Commands.CommandIds.ApplicationStateChanged, null);

}

FMSPages.PageComponent.prototype = {

getFocusedCommands: function () {

ULS_SP();

return [];

},

getGlobalCommands: function () {

ULS_SP();

return getGlobalCommands();

},

isFocusable: function () {

ULS_SP();

return true;

},

receiveFocus: function () {

ULS_SP();

return true;

},

yieldFocus: function () {

ULS_SP();

return true;

},

canHandleCommand: function (commandId) {

ULS_SP();

return commandEnabled(commandId);

},

handleCommand: function (commandId, properties, sequence) {

ULS_SP();

return handleCommand(commandId, properties, sequence);

}

}

// Register classes

FMSPages.PageComponent.registerClass('FMSPages.PageComponent',

CUI.Page.PageComponent);

FMSPages.PageComponent.instance = new FMSPages.PageComponent();

// Notify waiting jobs

NotifyScriptLoadedAndExecuteWaitingJobs("/_layouts/FMSPages/PageComponent.js");



Change <FMSPages> to your .