Tech Space

The Technical Solution Space for SharePoint 2010, MOSS 2007, and .Net (C#, VB.Net)


























SharePoint Group

Active Directory Group

Members of this group can be added/removed from within SharePoint. The
permission to add or remove users from the group can be delegated to SharePoint
users.

Members of this group can be managed within Active Directory. Only Active
Directory administrators have the permission to modify group memberships.

Members of this group can be visible to users.

Members of this group are not visible to users.

Cannot contain another SharePoint group as member.

Can contain another Active Directory Group.

Must have a unique name on site collection level. The name is the unique
identifier of the group.

Can cause serious problems in lage scale scenarios: A user might only be a
member of 1024 Active Directory groups (recoursively). If this number is reached
the user is no longer able to log on to Windows.

Read the
Microsoft documentation for more information.

Can contain SharePoint users that do not exist in the Active Directory.

If you set Current Navigation to “Display the same navigation items as the parent site” and if you don’t find the same navigation items as of the parent site, you might need to add an EnableInheritance="True" attribute to the

PublishingNavigation:PortalSiteMapDataSource as in this example:

SiteMapProvider="CurrentNavSiteMapProvider"
EnableViewState="true"
StartFromCurrentNode="true"
StartingNodeOffset="0"
ShowStartingNode="false"
TrimNonCurrentTypes="None"
EnableInheritance="True"/>

SPFieldMultiLineText sampleField = sampleListItem.Fields["Sample"] as SPFieldMultiLineText;

string sampleText = sampleField.GetFieldValueAsText(sampleListItem["Sample"]);

//


// Returns the value of an Url-Field.
//


public static string GetFieldValueUrl(this SPListItem item, string fieldName)
{
if (item != null)
{
SPFieldUrlValue urlValue = new SPFieldUrlValue(item[fieldName] as string);
return urlValue.Url;
}
else
{
return string.Empty;
}
}

Example:

// Get the url of a SPFieldUrl field
string url = item.GetFieldValueUrl("URL");



//
// Sets the value of an URL-Field.
//


public static void SetFieldValueUrl(this SPListItem item, string fieldName, string url, string description)
{
if (item != null)
{
item[fieldName] = new SPFieldUrlValue()
{
Description = description,
Url = url
};
}
}


Example:

// Set the url and description of a SPFieldUrl field
item.SetFieldValueUrl("URL", "http://www.TestSite.com", "Test' Blog");

///


/// Set the values of a Lookup-Field with multiple values allowed.
///


public static void SetFieldValueLookup(this SPListItem item, string fieldName, IEnumerable lookupValues)
{
if (item != null)
{
SPFieldLookup field = item.Fields.GetField(fieldName) as SPFieldLookup;

SPFieldLookupValueCollection fieldValues = new SPFieldLookupValueCollection();

foreach (string lookupValue in lookupValues)
{
fieldValues.Add(GetLookupValue(item.Web, field, lookupValue));
}
item[fieldName] = fieldValues;
}
}


Example:

//Set the value of a SPFieldLookup field with multiple values allowed

string[] values = {"Hamburg", "London" };
item.SetFieldValueLookup("MultiLookupFieldName", values);

///


/// Sets the value of a Lookup-Field.
///


public static void SetFieldValueLookup(this SPListItem item, string fieldName, string lookupValue)
{
if (item != null)
{
SPFieldLookup field = item.Fields.GetField(fieldName) as SPFieldLookup;
item[fieldName] = GetLookupValue(item.Web, field, lookupValue);
}
else
{
item[fieldName] = null;
}
}


Example:

// Set the value of a SPFieldLookup field

item.SetFieldValueLookup("LookupFieldName", "LookupValue");

//


// Returns the value of a Lookup-Field with multiple values.
//


public static IEnumerable GetFieldValueLookupCollection(this SPListItem item, string fieldName)
{
List result = new List();
if (item != null)
{
SPFieldLookupValueCollection values = item[fieldName] as SPFieldLookupValueCollection;

foreach (SPFieldLookupValue value in values)
{
result.Add(value.LookupValue);
}
}
return result;
}


Example:
// Read lookup values of a SPFieldLookup field with multiple values allowed

IEnumerable values = item.GetFieldValueLookupCollection("MultiLookupFieldName");

//


// Returns the Single Value of a Lookup Field.
//


private static string GetFieldValueLookup(this SPListItem item, string fieldName)
{
if (item != null)
{
SPFieldLookupValue lookupValue = new SPFieldLookupValue(item[fieldName] as string);
return lookupValue.LookupValue;
}
else
{
return string.Empty;
}
}


Example:
// Reads the value of a SPFieldLookup field
string value = item.GetFieldValueLookup("LookupFieldName");

Recently discovered an issue in SharePoint 2007 when creating a new Page under Pages Library, we were getting "Access Denied" error message in "CreatePage.aspx" page. The users accessing the site have "Full Control" and they are getting the "Create Page" option in the "Site Actions" menu, so this should not be a security problem. This was really shocking and finally could find a solution for the same. The User or Group needs to also have "Read" permission to the master page gallery, and then this works fine.
Resolution:

  • Go to Site Actions -> Site Settings -> Modify All Site Settings.
  • Go to Galleries -> Master pages and page layouts.
  • Within the Master pages library/list, Select Settings -> Document Library Settings.
  • Select Permissions for this document library.
  • Add "Restricted Read" access to the User or Group.

After this we should not have any issue in creating Pages in pages library.

A SharePoint Permission Levels are group of permissions that can be granted to users or SharePoint groups so that they can perform specific actions on securable objects such as a site, library, list, folder, item, or document on your site. Permission levels allow you to group permissions and apply them to users and SharePoint groups on various sites in your SharePoint.

When you create a SharePoint site, there are five permission levels provided by default:

  • Full Control: allows users or groups full control over a site. Full Control is the least restrictive permission level. You can not modify or remove this permission level.

  • Design: allows users or groups to view, add, update, delete, approve, and customize lists, libraries, and pages on your site, including themes and style sheets.

  • Contribute: allows users or groups to view, add, update, and delete previously created list items and document libraries.

  • Read: allows users or groups to read pages on the site including the resource libraries. Read is the most restrictive permission level.

  • Limited Access: is a permission level that is automatically assigned to a user or group and therefore cannot be directly assigned by the administrator. It is used when you assign the users or groups to a child object of a parent object to which they do not have access. You can not modify or remove this permission level.

Click on below image to enlarge...