Wednesday, July 1, 2015

Sharepoint 2007 - Access Denied when you try to edit

Recently I received an “Access Denied” error when I try to edit the list item in SP 2007.

I found the following solution from here (I coped same text below), which resolved the issue.

 

Here is the situation:

  • In a site collection, you make a new list/document library in any sub-site or the main website.
  • You then add a new item/document to the folder, and then attempt to edit the item
  • You then see something along the lines of "Access Denied" , even if you are on the system account.
  • This happens with every new list you create on any site or subsite.
Your problem is a corrupted field definition at the site collection level.

Specifically the "Effective Permissions Mask" is missing an attribute in it's xml scheme -

RenderXMLUsingPattern="TRUE"

The fix comes in 3 steps:

1. Update your server to the most recent cumulative update package (Service pack 2 or greater). You can get more information about this from the Sharepoint team blog post on SP2. Included in SP2 is a hotfix that prevents this from occurring ever again on any other site collections, but it does not fix sites already effected by it.


2. To fix sites that are already having this problem, first we need to fix the field definition. Thanks to Vicki Dillon who pointed me in the right direction (but the wrong field =) )

The easiest way to accomplish this is to use: sharepoint manager 2007


  1. Run sharepoint manager 2007 and navigate to the site collection you are having problems with.
  2. Expand the site collection until you see "Fields"
  3. Scroll down this long list until you come to "Effective Permissions Mask" (also goes by the static name of PermMask )
  4. Go to the SchemaXML, copy it out into notepad to wordpad, and add the following value:
  5. RenderXMLUsingPattern="TRUE"
    (I just tacked that onto the end, right before version="1")

This will prevent new lists from being created with out the RenderXMLUSingPatter=True value.

3. Now to fix the lists you already have made that need fixing.. You can either do this using SPmanger or you can do my favored option and fire up visual studio and compile the following code:

using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.SharePoint;
using System.Xml;
namespace CA_TestingHotfix
{
class Program
{
static void Main(string[] args)
{
FixField(args);
}
static void FixField(string[] args)
{
string RenderXMLPattenAttribute = "RenderXMLUsingPattern";
//Console.WriteLine("Please enter the URL of the site: (Press enter after typing):");
string weburl = args[0];
//Console.WriteLine("Please enter the Document Library Name: (Press enter after typing):");
string listName = args[1];
SPSite site = new SPSite(weburl);
SPWeb web = site.OpenWeb();
SPList list = web.Lists[listName];
SPField f = list.Fields.GetFieldByInternalName("PermMask");
string s = f.SchemaXml;
Console.WriteLine("schemaXml before: " + s);
XmlDocument xd = new XmlDocument();
xd.LoadXml(s);
XmlElement xe = xd.DocumentElement;
if (xe.Attributes[RenderXMLPattenAttribute] == null)
{
XmlAttribute attr = xd.CreateAttribute(RenderXMLPattenAttribute);
attr.Value = "TRUE";
xe.Attributes.Append(attr);
}
string strXml = xe.OuterXml;
Console.WriteLine("schemaXml after: " + strXml);
f.SchemaXml = strXml;
}
}
}

Since this touches the Sharepoint Model directly, remember to add the assembly reference to your local copy of Microsoft.sharepoint.dll to avoid compiling errors. Thanks to Jeff1024 for posting this code he got from the microsoft support team.

Run the program on the local server from the command line with two variables, the first one is the site that the list you are fixing is located in, the second is the name of the list to fix.

Tuesday, May 19, 2015

SharePoint 2013 Manage Services link missing

I noticed “Manage Services on Server” link is missing from Central Administration, I know it should be there under System Settings.

 

After google, I found its a common issue most users have and solution is “Try running IE with elevated privileges, (run as administrator)”

Friday, August 1, 2014

Finding Access Rights for Specific User in SharePoint 2007 using Powershell

Today I got a ticket saying, two users are not able to access the SharePoint site and not sure whether they have permissions or not. If they have what kinds of permissions? Since SharePoint 2007 don’t have an option to check, we depend on either on custom code or Powershell.

 

I want to do this pretty quick because of the ticket, I googled for powershell script and found the following site which really works well

 

http://www.sharepointdiary.com/2013/01/audit-user-permissions-in-sharepoint.html

 

Here is the code I got it from above mentioned site and made very few changes to make it dynamic

[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint") #DECLARE VARIABLES [string]$siteUrl = $args[0] [string]$userToFind = $args[2] #IF MISSING PARM FOR SITE URL, ASK FOR INPUT TO FILL if($args.length -eq 0) { DisplayMissingParametersMessage } function DisplayMissingParametersMessage { #Write-Output "You are missing a parameter for 'Site URL'" $script:siteURL = Read-Host "Enter Site URL" $script:userToFind = Read-Host "Enter User to Find" } #Get All Web Applications Function global:Get-SPWebApplication($WebAppURL) { if($WebAppURL -eq $null) #Get All Web Applications { $Farm = [Microsoft.SharePoint.Administration.SPFarm]::Local $websvcs = $farm.Services | where -FilterScript {$_.GetType() -eq [Microsoft.SharePoint.Administration.SPWebService]} $WebApps = @() foreach ($websvc in $websvcs) { foreach ($WebApp in $websvc.WebApplications) { $WebApps = $WebApps + $WebApp } } return $WebApps } else #Get Web Application for given URL { return [Microsoft.SharePoint.Administration.SPWebApplication]::Lookup($WebAppURL) } } Function global:Get-SPSite($url) { if($url -ne $null) { return New-Object Microsoft.SharePoint.SPSite($url) } } Function global:Get-SPWeb($url) { $site= Get-SPSite($url) if($site -ne $null) { $web=$site.OpenWeb(); } return $web } Function GetUserAccessReport($WebAppURL, $SearchUser) { #Get All Site Collections of the WebApp $SiteCollections = Get-SPWebApplication($WebAppURL) $SiteCollections= $SiteCollections.Sites #Write CSV- TAB Separated File) Header "URL `t Site/List `t Title `t PermissionType `t Permissions" | out-file UserAccessReport.csv #Check Whether the Search Users is a Farm Administrator $ca= [Microsoft.SharePoint.Administration.SPAdministrationWebApplication]::Local.Sites[0].RootWeb #Get Central Admin $AdminSite = Get-SPWeb($ca.URL) $AdminGroupName = $AdminSite.AssociatedOwnerGroup.Name $FarmAdminGroup = $AdminSite.SiteGroups[$AdminGroupName] foreach ($user in $FarmAdminGroup.users) { if($user.LoginName -eq $SearchUser) { "$($AdminSite.URL) `t Farm `t $($AdminSite.Title)`t Farm Administrator `t Farm Administrator" | Out-File UserAccessReport.csv -Append } } #Check Web Application Policies $WebApp= Get-SPWebApplication $WebAppURL foreach ($Policy in $WebApp.Policies) { #Check if the search users is member of the group if($Policy.UserName -eq $SearchUser) { #Write-Host $Policy.UserName $PolicyRoles=@() foreach($Role in $Policy.PolicyRoleBindings) { $PolicyRoles+= $Role.Name +";" } #Write-Host "Permissions: " $PolicyRoles "$($WebAppURL) `t Web Application `t $($AdminSite.Title)`t Web Application Policy `t $($PolicyRoles)" | Out-File UserAccessReport.csv -Append } } #Loop through all site collections foreach($Site in $SiteCollections) { #Check Whether the Search User is a Site Collection Administrator foreach($SiteCollAdmin in $Site.RootWeb.SiteAdministrators) { if($SiteCollAdmin.LoginName -eq $SearchUser) { "$($Site.RootWeb.Url) `t Site `t $($Site.RootWeb.Title)`t Site Collection Administrator `t Site Collection Administrator" | Out-File UserAccessReport.csv -Append } } #Loop throuh all Sub Sites foreach($Web in $Site.AllWebs) { if($Web.HasUniqueRoleAssignments -eq $True) { #Get all the users granted permissions to the list foreach($WebRoleAssignment in $Web.RoleAssignments ) { #Is it a User Account? if($WebRoleAssignment.Member.userlogin) { #Is the current user is the user we search for? if($WebRoleAssignment.Member.LoginName -eq $SearchUser) { #Write-Host $SearchUser has direct permissions to site $Web.Url #Get the Permissions assigned to user $WebUserPermissions=@() foreach ($RoleDefinition in $WebRoleAssignment.RoleDefinitionBindings) { $WebUserPermissions += $RoleDefinition.Name +";" } #write-host "with these permissions: " $WebUserPermissions #Send the Data to Log file "$($Web.Url) `t Site `t $($Web.Title)`t Direct Permission `t $($WebUserPermissions)" | Out-File UserAccessReport.csv -Append } } #Its a SharePoint Group, So search inside the group and check if the user is member of that group else { foreach($user in $WebRoleAssignment.member.users) { #Check if the search users is member of the group if($user.LoginName -eq $SearchUser) { #Write-Host "$SearchUser is Member of " $WebRoleAssignment.Member.Name "Group" #Get the Group's Permissions on site $WebGroupPermissions=@() foreach ($RoleDefinition in $WebRoleAssignment.RoleDefinitionBindings) { $WebGroupPermissions += $RoleDefinition.Name +";" } #write-host "Group has these permissions: " $WebGroupPermissions #Send the Data to Log file "$($Web.Url) `t Site `t $($Web.Title)`t Member of $($WebRoleAssignment.Member.Name) Group `t $($WebGroupPermissions)" | Out-File UserAccessReport.csv -Append } } } } } #******** Check Lists with Unique Permissions ********/ foreach($List in $Web.lists) { if($List.HasUniqueRoleAssignments -eq $True -and ($List.Hidden -eq $false)) { #Get all the users granted permissions to the list foreach($ListRoleAssignment in $List.RoleAssignments ) { #Is it a User Account? if($ListRoleAssignment.Member.userlogin) { #Is the current user is the user we search for? if($ListRoleAssignment.Member.LoginName -eq $SearchUser) { #Write-Host $SearchUser has direct permissions to List ($List.ParentWeb.Url)/($List.RootFolder.Url) #Get the Permissions assigned to user $ListUserPermissions=@() foreach ($RoleDefinition in $ListRoleAssignment.RoleDefinitionBindings) { $ListUserPermissions += $RoleDefinition.Name +";" } #write-host "with these permissions: " $ListUserPermissions #Send the Data to Log file "$($List.ParentWeb.Url)/$($List.RootFolder.Url) `t List `t $($List.Title)`t Direct Permissions `t $($ListUserPermissions)" | Out-File UserAccessReport.csv -Append } } #Its a SharePoint Group, So search inside the group and check if the user is member of that group else { foreach($user in $ListRoleAssignment.member.users) { if($user.LoginName -eq $SearchUser) { #Write-Host "$SearchUser is Member of " $ListRoleAssignment.Member.Name "Group" #Get the Group's Permissions on site $ListGroupPermissions=@() foreach ($RoleDefinition in $ListRoleAssignment.RoleDefinitionBindings) { $ListGroupPermissions += $RoleDefinition.Name +";" } #write-host "Group has these permissions: " $ListGroupPermissions #Send the Data to Log file "$($Web.Url) `t Site `t $($List.Title)`t Member of $($ListRoleAssignment.Member.Name) Group `t $($ListGroupPermissions)" | Out-File UserAccessReport.csv -Append } } } } } } } } } #Call the function to Check User Access GetUserAccessReport $siteUrl $userToFind
Wednesday, October 23, 2013

How to Log Errors in SharePoint Hosted Apps?

It is most common thing to log error message if some exception occurs within the code, so that user can find out what causing the error. It is straight forward if you using Server side object model. Since Hosted apps only use JavaScript object model and its bit new to many of us, not sure which namespace/class to use.

 

We use SP.Utilities.Utility.logCustomAppError method to log the app errors. Following is the sample code

 

 

function onFail(sender, args) {

    logAppError(args.get_message() + '\n' + args.get_stackTrace());
}

function logAppError(message) {
    SP.Utilities.Utility.logCustomAppError(context, message);
    this.context.executeQueryAsync();
}

Wednesday, October 16, 2013

SharePoint 2013 App Model – How to View list With in APP

If you working on SharePoint 2013 APP, at some point you defiantly want to see list items contained within the app. Unfortunately there is no navigation to traverse to list.

 

To view specific list in “APP Web”, you directly type the url which specified in the following format in browser

http://<APP WEB URL>/<APP NAME>/Lists/<List Name>/AllItems.aspx

Ex: http://app-0eb6021fad963e.apps.com/sites/SP2K13/WhiteCaseEDARAPP/Lists/Calendar/AllItems.aspx

 

If in case you want to see the List settings,

  • Click “Modify View” under List tab

image

  • Click on “Settings” link as shown below

image

Friday, August 30, 2013

SharePoint 2007 – Custom Alert Template Issue

Recently one of our Business user requested to use “Custom Alerts on old SharePoint” even though we are in the process of upgrading to SharePoint 2013.

 

Anyway I found a nice article to implement “Custom Alert Templates” here. This is what I did, in simple steps.

  • Created a copy of “AlertTemplates.xml” found in 12 hive\Templates\XML
  • Created a new “AlertTemplate” section with in the XML and gave the unique name (simply copy the GeneraicList and renamed the Name)
  • Made couple of changes to Styles and layout (adding new tables to show Company logo)
  • Ran the STSADM command to update the template
  • Create a  small tool in VS to update the template name to specific list
  • Reset the IIS
  • Reset the SharePoint Timer Service

 

Even though I followed same as mentioned in the article, still alert emails are defaulting to the old template no matter what i did (Even I made exact changes to generic list section to see at least its falling into that)

 

After spending couple of days, I removed existing alerts on the list and created new one. Now i see the emails with update template.

I found out that, if we already have alerts setup on the list before updates, even you change the list to use different template (through code), SharePoint still sends alert emails using the template that was assigned to the list at the time of Alert setup.

 

Lesson learned !!!

Tuesday, July 9, 2013

SharePoint 2013 - “We’re having a problem opening this location in File Explorer, Add this web site to your Trusted sites list and try again”

I got the following error, when I try to open the library within file explorer, I received following error message

 

“We’re having a problem opening this location in File Explorer, Add this web site to your Trusted sites list and try again”

image

As it says, i tried to add the current site to Trusted List, but still having the issue to open in file explorer. After goggling a bit, I found that I have to enable the “WebClient” service.

 

Steps

1. Go to Run, type “Services.msc” and press Enter.

2. Select “WebClient” service and start the service, if you already have.

For me it’s not showing, so I have to Install “Desktop Experience” feature. To do that

1. Go to Run, type “Server Manager” and press Enter.

2. Select Features and then select Add Features

image

image

3. Select “Desktop Experience” checkbox and select “Add Required Features” on following popup screen

image

4. Click “Next”

5. Click “Install”

6. Once you restart the computer, start the “WebClient” service.

image

Wednesday, November 14, 2012

Get Public Key Token From Visual Studio

To add a command within Visual Studio

  • Got to Tools and then select External Tools
  • Click Add Button
  • Name it what ever you want, I name it “Get SN Token”
  • on Command text, select following location

    C:\Program Files\Microsoft SDKs\Windows\v6.0A\Bin\sn.exe

  • On Arguments, type following

    -Tp $(TargetPath)

image

Monday, May 14, 2012

How to connect Oracle from SQL Server Management Studio

Recently I am working with Oracle database and I want to see the list of tables and views. As we all know its not as friendly as SQL server. So I want to connect (Linked Server) the oracle to SQL SERVER for quick view of the data. Here are the steps I followed to setup a linked server.

  1. Install Oracle Database 10g Client
    • Select the Custom Installation
    • Select the following under available products components
      • Oracle Database utilities
      • SQL * Plus
      • Oracle windows Interfaces
        • Oracle ODBC Driver
        • Oracle Provider for OLEDB
        • Oracle Data Provider for .NET
      • Oracle Net
  2. At the point where we have to do the configuration, enter the following information
    • Service Name (may not be service name, but it is the first box that you type something in) – enter ORADB1 (for example)
    • Then select TCP
    • In the next box enter you Oracle DB server name where you want to connect.
    • Change the port to 1501 (for example)
    • If there is a textbox for Net Service name - it is ORADB1 (for example)
  3. REBOOT
  4. Open SQL Server management Studio and right click on “OraOLEDB.Oracle” under Server Objects –> Linked Servers –> Providers and Select Properties. Here Enable “Allow inprocess”
  5. Right click on Linked Server and select “New Linked Server”. Enter the following
    • Linked Server : A name of your choice
    • Provider : Oracle Provider for OLE DB
    • Product Name : A name of your choice
    • Data Source : This must match the Host you defined in TNSNAMES.ora which you can find in C:\oracle\product\10.2.0\client_2\NETWORK\ADMIN (mine is client_2, yours might be different).
    • Under Security tab, Select “Be made using this security context” and enter user name and password to connect oracle db.

 

Now I can see the Oracle data into SQL Server management studio and able to query if I want to.

SELECT * FROM [LINKED SERVER NAME]..[NAME Appears before Table name].[TABLE NAME]

Monday, October 17, 2011

Could not find UpdatePanel with ID 'XXXX'. If it is being updated dynamically then it must be inside another UpdatePanel

I working on a project where I need to create a connected web parts in SharePoint. I created these web parts and wrap it in update panels. Also I am using the exception handling, so that if any error occurs in the code, I just clearing all the controls in the update panel and created a label control to show detailed error message. Everything works normally (update contents in each web part) if I do not get any error.

But if I get any error in the code, exception shows without any JavaScript error when page loads. Next I made some changes in the filters and hit submit button, now I am getting the JavaScript error as shown below.

Could not find UpdatePanel with ID 'ctl00_m_g_bcc7da50_1d6b_4979_8186_4246cbd7ca34_udpItemListingWebPart'. If it is being updated dynamically then it must be inside another UpdatePanel

image

I couldn’t figure it out what was causing this error for couple of hours. I know there is some thing wrong with the update panel and I closely look into the error message. Since error message says “It is being updated dynamically” and I changed the UpdateMode to “Conditional”.

 

Now It’s working without any JavaScript error. :)

Friday, September 23, 2011

How Does Your Website Look on Different Mobile Phones?

You have web site and want to test in different mobiles to see how it looks?

Here is the solution for you. Use .

 

Want to know more, Check this .

Wednesday, September 21, 2011

How To Take A Screenshot In HP TouchPad

Many of you want to take a screenshots with in their TouchPad for various reasons like show off to your friends, reviews in your blogs, etc., For whatever reason you want, you can do it using your TouchPad without purchasing any screenshot application.

Here is the quick tip which will show you how to take a screenshot in your HP TouchPad and transfer it to your PC.

  1. Go to the screen you would like to create a screenshot.
  2. Now hold down Home button and press the power button until you hear a sound something like camera click sound. HP-TouchPad
  3. Captured screenshots will be stored in “Screen Captures” folder and you can view them in “Photos & Videos” app under Apps tab in your TouchPad.
  4. To transfer files, you need to plug the TouchPad into your computer and turn on USB drive mode or you can email to yourself.
  5. That’s it. Simple ha…

 

Thursday, September 8, 2011

Blogger Template Design

I found a nice article on How to design your own custom blogger template? here

Tuesday, September 6, 2011

SharePoint DateTime Control Date Format

If you are working with DateTime Control in SharePoint, you might have a requirement to show date format (For example DD/MM/YYYY) based on the user regional setting instead of US date format (MM/DD/YYYY)

 

You can specify the regional settings locale id to DateTime local id on Page Load

 

int localId = Convert.ToInt32(SPContext.Current.RegionalSettings.LocaleId); 
dtpcStartDate.LocaleId = localId;


If you want to change the default date format, no matter what the user regional setting is, you can do it my writing the custom control by deriving from the Microsoft.SharePoint.WebControls.DateTimeControl.



 

public class CustomDatePicker : Microsoft.SharePoint.WebControls.DateTimeControl
{
protected override void OnPreRender(EventArgs e)
{
base.OnPreRender(e);
TextBox tb= (TextBox)this.Controls[0];
DateTime dt = DateTime.Parse(tb.Text);
tb.Text = dt.ToString("dd/MM/yyyy");

}

}
}


Note: For above code, I used the Autopostback = true to trigger OnPreRender event until i figure it out how to trigger onDateChangeed event client side.

Thursday, August 25, 2011

How to show dates which has TBD at the end of the SharePoint List?

I am working on the two custom web parts, one of them is filter web part and another one is a results web part which shows data filtered from the SharePoint list based on the user selection. In the filter web part, we have a date range where they can specify certain range or just leave it empty so that we just return records which are greater than or equal to current date. Since dates are not mandatory in my SharePoint list (user don’t have a date and it is TBD – to be decided), it either shows empty dates at the top if i order by dates in ascending order without any filter criteria or it won’t show empty dates if i apply filter criteria.

 

But my requirement is,

  • we should show empty dates (TBD)
  • TBD should be at the end of the result set and not in the beginning of the result set.

To implement this, we created a calculated field and use the following formula

=IF(ISBLANK(DateColumn),DATE(2099,1,1),DateColumn)

 

Where

DateColumn – is a column we used to store the user selected date in the List.

 

Above formula we used max date (01/01/2099), so that we can easily use “Greater than or equal to” to compare with other dates and also sort dates in ascending order so that max dates will so at the end.

 

In the results web part, we are using XSLT to show the data and in that we are checking dateColumn empty or not, if empty show TBD or else show actual date.

 

Hope this helps some one and have a happy programming.

Thursday, August 11, 2011

Connected Web Part Approaches

I found a very nice article about Connected web parts.

Thursday, April 14, 2011

SharePoint 2010 Certification Information

URLS:

http://www.microsoft.com/learning/en/us/certification/cert-sharepoint-server.aspx#tab2

 

Videos

http://channel9.msdn.com/learn/courses/SharePoint2010Developer

Thursday, February 24, 2011

No Edit Page Option in Site Actions in MOSS 2007

Today I tried to Edit the Form pages to add Web Parts, for somehow, i Couldn’t see the option under Site Actions. I found a short cut to edit the page using ?ToolPaneView=2.

For Eg: http://SHAREPOINTSITE/Lists/Test List/NewForm.aspx?ToolPaneView=2

Tuesday, February 22, 2011

Navigate to Web Part Maintenance Page in SharePoint

As most of you know that there are two options to remove web parts from a SharePoint  page.

  • Close – preserves the web part’s configurations and customizations in Closed Web Parts gallery.
  • Delete – deletes permanently.

If you want to see list of all closed web parts on the page, you have to go to Web part maintenance page. However, there is no easy way to get to this page.

 

A quick way to navigate to Web Part maintenance page in both SharePoint 2007 and SharePoint 2010

 

Option 1:

Copy the following code in browser and make changes accordingly,

http://[SERVERNAME]/_layouts/spcontnt.aspx?pageview=shared&url=[Your Web Part Page URL] (For Example: /FirmCalendar/pages/default.aspx)

 

Option 2: (Much easier)

Just append the querystring “?Contents=1” to any page that contains Web parts as shown below,

http://[SERVERNAME]/default.aspx?contents=1

 

Note: In SharePoint Server 2010, a closed Web part no longer consumes the system resources as open Web parts do.

Thursday, February 10, 2011

Error occurred in deployment step 'Add Solution': Exception from HRESULT: 0x81070215

Here I got another error which won’t tell about what the error is. so, i went to SharePoint root folder (14 hive) and checked the log file. Log file contains the following error message

 

Failed to open the file 'C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\Template\Features\WebGTSTemplates\GTSProjectTemplate\onet.xml'.   

 

I Checked the ONET.xml file properties and i found that i forgot to change the Deployment Type to Element File. Once i changed, now i am able to deploy my feature successfully.

image

Hope this helps some one’s life easier. If so, leave some comments.