Showing posts with label sharepoint. Show all posts
Showing posts with label sharepoint. Show all posts

Wednesday, 20 June 2012

Sort Folders (Custom Order) in SharePoint Document Library

One of my friend recently asked me this question about sorting the folders (not in alphabetical order) in a document library. The sort order has to be custom and user should be able to specify the order in which folders should appear. Example sort order

Top
Middle
Bottom


In order to implement this you can create a new folder content type and add an order column to this content type. You do need to have the appropriate rights to do so.

The steps would be as follows.


  • Go to Site Actions
  • Go to Site Settings
  • Go to Site Content Types
  • Click Create New
  • Give it a name such as Folder Order
  • Select Parent Content Type from as of Folder Content Types
  • Select Folder as the Parent Content Type
  • You can create a new group or leave it in custom content types
  • Click OK
  • At the content type settings click Add from new site column
  • Create a site column called Item Order or something similar, select the type as Number
  • Click OK
  • Go to the list where you want the folders to be ordered
  • Go to the list settings
  • Go to Advanced Settings
  • Select allow management of content types
  • Select No for display new folder command on the new menu
  • Click OK
  • You should now see an area called content types, leave the document as is
  • Click Add from existing site content types
  • Select the Folder Order (or whatever you named it)
  • Click OK


That's it you can now create a folder structure with the order column and order your items as you need. 

Tuesday, 13 March 2012

PowerPivot Gallery shows Red X's for Icons

After publishing PowerPivot workbooks to the PowerPivot Gallery, the gallery shows Red X's instead of an image of the workbook.

When a .xlsx is uploaded or published to Gallery, behind the scene, a process (GetSnapshot.exe) is created that ultimately generates the snapshot image (.png file) and saves in C:\Windows\temp. Here are some of the troubleshooting steps for this scenario:

1. Make sure Excel services is rendering workbooks.

2. If you you have Internet Explorer 9 installed on your Farm servers you need to install Sql 2008 R2 SP1 for PowerPivot for SharePoint.

a. if you cannot upgrade to SP1 you can manually make the fix with the below steps.

In %Common Files%\Microsoft Shared\Web Server Extensions\14\Template\Layouts\PowerPivot you will find a file called ASRGLoader.htm.



Make a copy of the file and call it ASRGLoader.orig.htm (this is so that if you mess up anything you can revert :)

Open asrgloader.html in notepad.

Search for a function called onXLFrameLoad

Replace the line

if (ewaFrame.document.readyState == 'complete') {

with the line
if ( (ewaFrame.document.readyState == 'complete') || (ewaFrame.document.readyState == 'interactive') ) {

. A simple test to see if a getsnapshot is being spawned is to:

a. start task manager on your Web Frong End and click “show processes from all users”

b. go to the document library and go to view “all documents” and just edit properties. This should cause GetSnapshot.exe to fire and you should see it under task manager and can see the account it is running under

4. You can run GetSnapshot.exe manually and pass in parameters site, url, guid (note guid can be whatever). One caveat though is that the .info and .png file are created in the user’s local temp directory if they are logged in (as I was)…otherwise it will be saved in the c:\windows\temp. You cannot use this method to manually create/replace a thumbnail. This will only tell you if GetSnapshot failed (maybe b/c it took too long or something)

a. http://blogs.msdn.com/b/mtn/archive/2010/10/15/how-to-manually-refresh-powerpivot-gallery-thumbnails.aspX

5. Look in C:\Windows\Temp for the thumbnail (.png) and the log file .INFO; .INFO file should report success or failure messages

6. The workbook might not contain any embedded PowerPivot data. If so, a thumbnail will not be generated.

7. The workbook might contain more than one data source. If so, a thumbnail will not be generated.

. If the file is a .rdl file, then the data source must be embedded in the report and it must use the PowerPivot OLEDB provider and point to a workbook (.xlsx) that is contained in the same document library (i.e. the Gallery). If not, a thumbnail will not be generated.
9. Verify Alternate Access Mappings are setup correctly.

10. Add the PowerPivot site to the trusted intranet sites for the account running Getsnapshot.exe

11. disable loopback check. http://support.microsoft.com/kb/926642

12. remove the check box for refresh on open in the workbook connection properties

13. Open Advanced Settings for the Document library(PowerPivot Gallery).

Under Opening documents in the browser change the setting to "open in the Browser".
(This option worked for me)

Monday, 13 February 2012

Creating Staff Directory Web part

Recently I had requirement to create a staff directory web part which intranet users can use to search for staff members in the organization. The web part displayed below use the people search to display results.


Search Results:





SCRIPT:

<script type="text/javascript" language="javascript">

//function for enter on keyboard and apostrophes in search strings
function txtWildPeopleFinder_KeyDown(e) {
if (e.keyCode == 13 || e.keyCode == 10) {
e.returnValue = false;
doWildPeopleSearch();
return false;
}
else {
return true;
}
}

function escapestr(str) {
return str.replace("'", "%22");
}

//staff search
function doWildPeopleSearch() {

var firstname = escapestr(document.all["firstname"].value);
var lastname = escapestr(document.all["lastname"].value);
var department = escapestr(document.all["department"].value);

var url = "";

if (firstname == "" && department == "" && lastname == "") {
alert ("Please enter first name, last name or department to search for a staff member.")
return;
}
// buliding url string
if (firstname != "") {
url += "FirstName%3A" + firstname;
}
if (lastname != "") {
if (url != "") url += "%20";
url += "LastName%3A" + lastname;
}
if (department != "") {
if (url != "") url += "%20";
url += "Department%3A" + department;
}

var staffSearchResultsPageUrl = "/search/Pages/peopleresults.aspx";

window.location = staffSearchResultsPageUrl + "?k=" + url;
return;
}
</script>

CSS:

<style type="text/css">
.label {
float: left;
width: 80px;
}
.staffDirectory div {
padding:5px 0px 0px 0px;
}
</style>

HTML:

<div class="staffDirectory">
<div>
Enter all or part of a name e.g. A will find all names beginning with A
</div>
<div class="label">
First Name:</div>
<div class="">
<input name="firstname" id="firstname" onkeydown="txtWildPeopleFinder_KeyDown(event)"
type="text" size="25" maxlength="55" /></div>
<div class="label">
Last Name:</div>
<div>
<input name="lastname" id="lastname" onkeydown="txtWildPeopleFinder_KeyDown(event)"
type="text" size="25" maxlength="55" /></div>
<div class="label">
Department:</div>
<div>
<input name="department" id="department" onkeydown="txtWildPeopleFinder_KeyDown(event)"
type="text" size="25" maxlength="55" />
</div>
<div>
<input type="button" value="Search" onclick="doWildPeopleSearch()"/>
</div>
</div>


Thursday, 9 February 2012

Creating SPNs and Kerberos Delegation - Reporting services in sharepoint integrated mode

There are a few prerequisites to setting up Kerberos delegation.

  1. Both sharepoint web sites and report server are now installed and configured.
  2. All computers accessing the application must be in the same domain.
  3. Kerberos ports must be open if going through a firewall.
  4. Client browsers must be setup to allow integrated authentication.
  5. Clients must be domain users.
  6. All clients must be running Windows 2000 or greater.
  7. All client’s browsers must be IE 5+


Probably the most likely culprit for not getting this Kerberos authentication to work is improper or duplicate SPN’s. Duplicate SPN’s can easily be created if the person that install say, SQL, is a domain admin and decides to run the setup under their domain admin account. What happens in this scenario, is the SPN for SQL server is automatically registered under that Domain Admin’s user account. Even if they go back and change the service to run under localsystem, Active Directory will still know of a SPN to SQL01′s SQL Server Service. This creates a duplicate SPN and will break your entire setup.

Duplicate spns can be found using following command in command prompt

setspn -x

if you see any duplicate spns then delete them by running follwoing command

setspn -d [SPN TO DELETE] [OBJECT FRM WHICH YOU WANT TO DELETE IT]

Example c:\>setspn -d MsSQLSvc/SQL01:1433 domainnamedomainadmin

Creating Necessary SPN’s
if sharepoint server is WEB01 and reporting server is REP01 then we need to setup following SPNS with both NETBIOS and FQNs

REP01:
1. SETSPN –a HTTP/REP01.xyz.local:80 [REPORTING SERVICE DOMAIN ACCOUNT]
2. SETSPN –a HTTP/REP01.xyz.local [REPORTING SERVICE DOMAIN ACCOUNT]
3. SETSPN –a HTTP/REP01 [REPORTING SERVICE DOMAIN ACCOUNT]
4. SETSPN –a HTTP/REP01:80 [REPORTING SERVICE DOMAIN ACCOUNT]

We will also need to set spn for the sql service i.e.

SETSPN –a MSSQLSvc/[REP01].xyz.local [SQL SERVICE ACCOUNT]
SETSPN –a MSSQLSvc/[REP01].xyz.local:1433 [SQL SERVICE ACCOUNT]
SETSPN –a MSSQLSvc/[REP01] [SQL SERVICE ACCOUNT]
SETSPN –a MSSQLSvc/[REP01]:1433 [SQL SERVICE ACCOUNT]


WEB01:

On the web end we need to specifiy SPNs for each sharepoint site including the central admin

SETSPN –a HTTP/[WEB ADDRESS]:[PORT NUMBER] [APP POOL DOMAIN ACCOUNT]

Allowing Constrained Delegation
1. Log on to the domain controller.

2. On the domain controller, click Start, click Administrative Tools, and then click Active Directory Users and Computers.

3. Expand the domain node, and then click Users.

4. Right-click the application pool identity user account, and then select Properties.

5. On the Delegation tab, verify that the Trust this user for Delegation to specified Services only option is selected.

6. Select Use Kerberos Only.

7. Click Add.

8. Click Users or Computers.

9. Enter the domain and user name of the account running the service that you want to have accept Kerberos credentials, and then click OK.

10. The Available Services values will appear for the account that you selected. Select the appropriate service and click OK.

Note:

This will normally be the Web service associated with the application pool identity that you are modifying or any services associated with data sources that you want to be able to access using Kerberos authentication.
1. Repeat steps 8 through 10 for each service that you want to accept credentials from this account.

2. Click OK to close the account properties dialog box.