Wednesday 29 February 2012

Handy shortcut key for visual studio code navigation

Ctrl + - and the opposite Ctrl + Shift + -

Move cursor back (or forwards) to the last place it was.

No more scrolling back or PgUp/Dwn to find out where you were.


Tuesday 14 February 2012

SPRello: A trello like interface for organizing items

An interface for organising items in SharePoint Lists - inspired by http://trello.com

sprello-screenshot1.png

A simple card/post it note like UI for displaying and organising items in SharePoint lists.



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

The responsive HTML5 master page for sharepoint 2010

Today I came across this blog about html5 responsive master page for sharepoint 2010 from kyle schaeffer. Handy,looks awesome and worth sharing.

“v5.master” is a simple HTML5 master page designed for SharePoint 2010. It makes good use of the amazing new features of both HTML5 and CSS3, including CSS3 media queries. The master page is extremely simplistic in nature, and is truly meant to serve as a framework for building your own SharePoint 2010 customizations.

SharePoint Gets Responsive

SharePoint has a knack for being rigid and difficult to customize. I’ve been working with responsive layouts for a while now, but the nature of SharePoint has thus far prevented me from making something that is as flexible as, say, this WordPress blog you’re reading right now. It’s easy-peasy to do this in WordPress, but SharePoint simply does too much. When you create a layout in SharePoint, you’re creating a layout that encompasses much more than just pages: you’ll have to contend with pages, web parts, lists, libraries, blogs, wikis, search, meeting workspaces, team sites, calendars, and the list goes on. With so much content to contend with, creating something that can contract to any width is a tall order to say the least.

To me, at least, the answer was simple: ignorance. I’m ignoring every part of SharePoint that I don’t care about. 90% of the sites that I create in SharePoint are publishing sites: public-facing with a focus on pages, navigation, and web parts. Now, that’s a list I can handle. The v5 master page uses a fluid layout that drops to a single column when the display size shrinks below 800 pixels in width. Check out the screens to see the flexibility in action:

Large/Desktop Displays:

Medium/Tablet Displays:

Small/Mobile Displays:

Read More


Restoring sharepoint site from content db backup - Sharepoint 2010

If web application doesn't exist on on your target server then create one.

Restore the content database backup (full database backup) on your WSS_Content on target server.

DETATCH ANY CONTENT DATABASES FROM THE TARGET WEB APPLICATION IN Central Administration

Application Management, select “Manage Content Databases” under the Database heading.

Select the target web application in the “Web Application” drop-down box at the top left, if it is not already selected.

Picture

Ensure there are no content databases for the target web application. If the list contains any content databases, click on each content database name. On the “Manage Content Database Settings” screen, select the “remove content database” checkbox and click OK.
Picture
Note: Make sure to log into your SharePoint 2010 SQL Server Instance at your convenience and delete any orphaned content databases that were removed from the web application in the step above.

ADD CONTENTDB THE CONTENT DATABASE USING STSADM.EXE

Using the stsadm.exe tool, run the addcontentdb command using the syntax below:

stsadm –o addcontentdb –url [URL] –databasename [DBName]
Picture
Once executed, the command window will update with a progress indicator as seen in the screenshot above. Once it is complete, you will either receive one of two messages:

Operation Completed Successfully


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.