Sunday, November 13, 2011

Unlock uploading file in SharePoint 2010

By default, SharePoint locked the uploading file with some extensions, these extensions may cause the damage your server and user will take advantage of uploading to send a script, virus and even the code executable and control your server from remoting. So, SharePoint has been locked by default to be sure your server to be protected safety.

You will get an error if you try to upload the file with restrictive high level:


However, in some case, you need to unlock to upload the file for internal process, or only in local. It's very simple by remove the extension out the locked list.


Go to Central Administration -> Web Application, on the Ribbon click on Blocked File Types, the remove the extension necessary. This is only effected on each Web Application. To be more safely, put it back the blocked list after finished the uploading, only open if it is really necessary.

Monday, October 24, 2011

Share a SharePoint Blog Post/Discussion Board to many Social Networking

Once the discussion board and blog has been published on the internet, the Administrator wish always sharing the interesting thing to everyone through Social Networking such as Facebook, Twitter,... There are many people  know your site if the post was shared to many ways, many sites...

Look at the picture:

Step by step:

1) Regist an account on http://sharethis.com

2) Login by this account, create an Get a button, then customize the number of networking, size, template,...

3) Get a code.

4) Open file thread.xsl in 14/Hive location LAYOUTS/XSL folder. Point to line at: 650 and paste this code:

<xsl:if test="(@BaseViewID='1' or @BaseViewID='2')">
// THE CODE FROM sharethis.com
</xsl:if>

THE CODE FROM sharethis.com as picture below:



5) Save and reset IIS.

Thursday, October 20, 2011

Fix Blog Comment bug for SharePoint 2010

SharePoint Bug:

Scenarios: Turn on anonymous access to the comment list with full functioning such as Delete/Add/Edit and View item.

Work As Design and Problem: If you logged into site by Anonymous,  of course, you can post the comment, edit and delete the comment. However, these comments which has created by Anonymous, all anonymous can view these comments although they are not approved. Especially, anonymous can be edit/delete the comment which posted by another anonymous. And then, if you logged into by authenticated account, you will not see these comment because they are not approved yet. That's so funny.

Resolve: If user log-in the site by anonymous and post the comment, item needs to be approved before showing on the page. So, after user click post comment button, they will see nothing change on the page. It's a little confuse but it should be.

More thing, although edit permission is turned on for anonymous but it should not be use in this scenarios, because no one knows who is edited and editing/deleting to be complicated. So, we must check if anonymous access and the comment has been approved, just show as normal.


Just change a little thing. Go go 14/hive and open folder Layouts/xsl, open the file blog.xsl and go to line at 418, insert the line:

<xsl:if test="($Userid &lt; 0 and $thisNode/@_ModerationStatus = 'Approved') or ($Userid &gt; 0)">
//SharePoint Code

and insert the line at 448 a close tag

</xsl:if>

See attach:

Warning: if follow this instruction, the WAD of SharePoint default will not keep correctly, this is also new view for end user and I think it should be change like this and make sense for all cases.

Friday, October 14, 2011

Access denied for Anonymous users with custom xslt

SharePoint Bug

Sometime I had a stress with SharePoint customization, especially on XSLT data transform.
My scenarios is:
- Create a custom view for any list.
- Customize XSLT to render UI for my stituation.
My Problem is:
- With authenticated users, it works fine and smoothly
- Got a notice: Access denied. You do not have permission to perform this action or access this resource for Anonymous users.



I am a "SharePointism", so the first thing I looked into the SharePoint log file. it's very lucky, I got the message: "Error while executing web part: System.UnauthorizedAccessException: Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))     at Microsoft.SharePoint.Library.SPRequest.UpdateWebPartCache(String bstrWebUrl, Boolean bAllUsers, String bstrID, Byte[]& ppsaData, Boolean fOMCall)     at Microsoft.SharePoint.WebPartPages.SPWebPartManager.CacheWriteInternal(Guid storageKey, Byte[] cacheData, Storage storage, Boolean omCall)     at Microsoft.SharePoint.WebPartPages.BaseXsltListWebPart.get_CustomizedXsl()     at Microsoft.SharePoint.WebPartPages.BaseXsltListWebPart.LoadXslCompiledTransform(WSSXmlUrlResolver someXmlResolver)     at Microsoft.SharePoint.WebPartPages.DataFormWebPart.GetXslCompiledTransform()     at Microsoft.SharePoint.WebPartPages.DataFormWebPart.PrepareAndPerformTra..."

Just guess that because I turned on the "Data Web Part Caching" and it seems turned on automatically. So, I disable (remove the checked) for this button. And....oh la la... it still doesn't work. However, we should not do like that because the message from SharePoint is not able to update "Cache". So, I tried to change the value CacheXslStorage="false" and ViewFlag="8", but it still end up with "Access denied".

However, i will work fine if there is an authenticated user view the blog detail first, then everybody can view this post without error. Maybe it's WAD or Bug of SharePoint 2010.

Update: We should not apply the cusomize xslt to ListXsltViewWebPart by UI in toolpane. We should open site by SPD, then change the property named "GhostedXslLink" is our customized xsl. This xsl is in layout/xsl folder of 14/hive. The content of this xsl file has reference to customized xslt.

Hope this help

Monday, October 10, 2011

Something in SharePoint (2007 & 2010)

There is a funny thing in SharePoint (in all versions)

1) List

With normal list the URL like http://server_name/site_name/Lists/List_Name
With documents list the URL like http://server_name/site_name/List_Name

2) Site

With normal site, all lists have the full controls on the list such as deleting, saving template,...
With blog site, the Posts list does not have permission to delete or save as the template and after save the blog site as template, we cannot restore the site correctly. All views of Posts list are generated as a list with the same name.

Friday, September 30, 2011

How to get all subsites if logged by Reader or Contributor

Sometime, we need to go through all sub-site of site collection to do something, however, it's very easy if you are logged in by Designer or Full Control. Because these account have full rights on subsites and the problem happens with Contributor or Reader. Look at the code:


SPWeb parent = SPContext.Current.Web;
foreach (SPWeb web in parent.Webs)
{
          try
          {
                    table.Merge(this.GetDataFromURL(new Uri(web.Url), schemaName, itemLimit));
           }
          catch (Exception ex)
         {
                //logger.Warn("DataBind::", ex);
         }
         finally
        {
              web.Dispose();
       }
}

The code runs without error but you will get the Access denied on the page and the stack trace shows full message like: "Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack." That's very bad practice. Because of requirement, there are some subsites that Contributors or Readers do not have permission to read. However, we must get the data from remaining subsites which they have the right to read the data.

The code will change to:


SPWeb parent = SPContext.Current.Web;
parent.Site.CatchAccessDeniedException = false;
foreach (SPWeb web in parent.Webs)
{
          try
          {
                    table.Merge(this.GetDataFromURL(new Uri(web.Url), schemaName, itemLimit));
           }
          catch (Exception ex)
         {
                //logger.Warn("DataBind::", ex);
         }
         finally
        {
              web.Dispose();
       }
}


We need to set property "CatchAccessDeniedException = false" for SPSite object. SharePoint will know that catch any site does have permission to read. As a result, you never get "Access denied" exception on page but you also never get data correctly, because the collection of Webs will throw exception if any subsite strict from user does not have permission.

The best practice for this issue is to get all subsites which Current user has the right to read, the code to change again:


SPWeb parent = SPContext.Current.Web;
parent.Site.CatchAccessDeniedException = false;
foreach (SPWeb web in parent.GetSubwebsForCurrentUser())
{
          try
          {
                    table.Merge(this.GetDataFromURL(new Uri(web.Url), schemaName, itemLimit));
           }
          catch (Exception ex)
         {
                //logger.Warn("DataBind::", ex);
         }
         finally
        {
              web.Dispose();
       }
}


Method "GetSubwebsForCurrentUser()" of  SPWeb just gets all subsites which current user is to be able to access, atleast, reading the data.

Monday, August 29, 2011

Error Posts List when create a blog site from blog site template!

Haizzzzzzz...., I was so happy when I was working on SharePoint, especially is SharePoint 2010. But! Still But and But...SharePoint 2010 seems to be stopped if we could not find out the error and these issues are a WAD or not...nobody knows. And the HOTFIX is the best choice to solve the problem.

This time, I show you guys a simple issue but it was not fixed in June 2011 hotfix.

Step 1) Create a blog site. Design by yours, Customize by yours...Look nice.

Step 2) Save as a template to be used for the second time or another server...

Step 3) Import this template and create a new blog site base on this template.

ahahaha...:D Issue........

Open the newsite, then go to Site Action and View All Site contents. You will see:


And...what's happen then? You can work on new site as normal, but you cannot save the site template from new site, sharepoint will give you an error because many links blog are the same but actually it's the only one.

I am using foundation with the simplest configuration.

Any body helps me? /Thankssssss

Friday, July 22, 2011

Resolved: using [Today] in formula of Calculated column.

Situation:
I have a check list is listing the domain name of customers who registered the domain with my services. I need to know the remaining of the validation date and send to customer an email. The expiration day is calculated from due date until today.

Problem:
I created a list with Due Date column with DateTime formated. Another column called remain days belongs to calculated with the formula like this: [Due Date] - [Today]. After click save, I got an error:


That means, I can not use the SP variables, but I can define a custom column with the formula had an existed SP variable such as [Today] and [Me]. And I have another solutions:

1) Create a new column named Today with type of DateTime
2) Modify the Remains column if you had created before. Change the formula to [Due Date] - [Today] with [Today] is a new column.
3) Delete [Today] column.

As a result, the Remains column is calculated from Due Date to today.

Sunday, July 17, 2011

How to connect to MICROSOFT##SSEE (Windows Internal Database) - SharePoint 2010

In a previous post, I introduced the way how to connect to internal sharepoint database. But the limited is just supported for SharePoint 2010.

In SharePoint 2010, something changed in the structure of Database such as the instance name is SERVER\SHAREPOINT instead of SERVER\SQLEXPRESS or SERVER\OFFICESERVERS,... or something like that.

And it's easy to understand that internal database also gives the way easiest to connect to database, just replace the instance name in connnection string to "SHAREPOINT": \\.\pipe\MSSQL$SHAREPOINT\sql\query

Sunday, July 3, 2011

Installing and Configuring Bamboo Discussion Board Plus for SharePoint

In forum view, there are two parts: Sticky topics and normal topics. Some important topics need to be shown at the top of the Discussion Board. By selecting the topics as sticky they will be displayed at the top under Sticky Topics. Other topics will be shown under the Topics section. All topics are sorted by the Last Posted time. In addition, each of the sticky topics is marked as sticky with a sticky icon () to the left of the title.


Read more at: http://community.bamboosolutions.com/blogs/bambooteamblog/archive/2011/07/01/installing-and-configuring-bamboo-discussion-board-plus-for-sharepoint.aspx