28 December 2015

Learn AngularJS in one day

Found a nice website/link to learn Angular JS in one day.

https://toddmotto.com/ultimate-guide-to-learning-angular-js-in-one-day/

Useful for refreshing basic Angular JS concepts in quick time.


21 December 2015

SharePoint 2013 - Problem in debugging and deploying SharePoint web-part

Recently we were developing a web-part for our SharePoint 2013 site. When we tried to connect to SharePoint 2013 site from Visual Studio 2013, we got following error -

Error occurred in deployment step ‘Recycle IIS Application Pool’: Cannot connect to the SharePoint site: http://<your sharepoint site>/. Make sure that this is a valid URL the SharePoint site is running on the local computer. If you moved this project to a new computer or if the URL of the SharePoint site has changed since you created the project, update the Site URL property of the project

Due to this error, we were not able to deploy web-part to SharePoint site directly from Visual Studio itself. We were also not able to debug the web-part.

Finally we found the solution for this problem. Visual studio 2013 runs as process vssphost5.exe. This process runs under an account. This account can be identified by going to Task Manager and looking at details of the process. This account needs to be given dbowner permissions on following SharePoint databases -

  • SharePoint site content database
  • SharePoint central admin content database
  • SharePoint configuration database
To find names of these databases, you can go to Central Admin --> Backup & Restore -->Perform Backup.

Once these permissions were given, we were able to deploy the web-part and debug it right from Visual Studio.

18 December 2015

Visual studio Dev Essentials Program - 6 months of pluralsight and other benefits

Sign up for Visual Studio Dev Essentials program and get access to exclusive benefits including free training, Azure credits and more.

https://www.visualstudio.com/en-us/products/visual-studio-dev-essentials-vs.aspx 

Pluralsight offer is for limited time only. Be sure to sign up before 31st Dec 2015.

Enjoy...




16 December 2015

SharePoint Online - How to remove a service principal name from service principal

Today I was configuring server to server authentication between SharePoint 2013 Azure and SharePoint Online. I was following the steps from this MSDN URL -

https://technet.microsoft.com/en-us/library/dn197169.aspx

Everything went on fine until I executed following commands -

$msp = Get-MsolServicePrincipal -AppPrincipalId $spoappid
$spns = $msp.ServicePrincipalNames
$spns.Add("$spoappid/$spcn")
Set-MsolServicePrincipal -AppPrincipalId $spoappid -ServicePrincipalNames $spns

I got following error in the last command -

Set-MsolServicePrincipal : Uniqueness violation. Property: ServicePrincipalNames.
At line:1 char:1
+ Set-MsolServicePrincipal -AppPrincipalId $spoappid -ServicePrincipalNames $spns
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : OperationStopped: (:) [Set-MsolServicePrincipal], MicrosoftOnlineException
    + FullyQualifiedErrorId : Microsoft.Online.Administration.Automation.UniquenessValidationException,Microsoft.Onlin
   e.Administration.Automation.SetServicePrincipal


I checked the values of existing Msol Service Principal with the help of following commands - 

$msp = Get-MsolServicePrincipal -AppPrincipalId $spoappid
$spns = $msp.ServicePrincipalNames
$spns

The output was in this format - 

00000003-0000-0ff1-ce00-000000000000/*.mydomain.com
00000003-0000-0ff1-ce00-000000000000/*.sharepoint.com
00000003-0000-0ff1-ce00-000000000000

I immediately found the problem. I was trying to add "*.mydomain.com" again to the service principal and it was already existing. I realized that I had added it earlier on a different server using a different certificate. But since that certificate was no longer valid, I have to re-register it with a new certificate but with same domain name. 

Searched a lot on internet but was not able to find how to remove a service principal name from a service principal.

Finally I found the solution in my original commands.

$msp = Get-MsolServicePrincipal -AppPrincipalId $spoappid
$spns = $msp.ServicePrincipalNames
$spns.Add("$spoappid/$spcn")
Set-MsolServicePrincipal -AppPrincipalId $spoappid -ServicePrincipalNames $spns

If you see these commands, I am adding my service principal name in service principal using

$spns.Add("$spoappid/$spcn")

Since this is a generic list, all I have to do is remove the same service principal name from generic list and again update the service principal.

$msp = Get-MsolServicePrincipal -AppPrincipalId $spoappid
$spns = $msp.ServicePrincipalNames
$spns.Remove("$spoappid/$spcn")
Set-MsolServicePrincipal -AppPrincipalId $spoappid -ServicePrincipalNames $spns

That's it. Simple and elegant solution. But spent quite some time figuring it out.


15 December 2015

SharePoint 2013 - GetUserEffectivePermissions returning incorrect results

Recently I was trying to get effective permission of a SharePoint user using client context (client side object model). I was trying to achieve this in SharePoint 2013 Provider Hosted App.

The method was executing sucessfully but when I was iterating through the effective permissions, I was getting false for all the permissions. Here is the sample code that I was using -

var spContext = SharePointContextProvider.Current.GetSharePointContext(Context);

using (var clientContext = spContext.CreateUserClientContextForSPHost())
{

    string userName = @"domain\username";

    var userPermissions = clientContext.Web.GetUserEffectivePermissions(userName);
    clientContext.ExecuteQuery();

    foreach (var permission in Enum.GetValues(typeof(PermissionKind)).Cast<PermissionKind>())
    {
        var permissionName = Enum.GetName(typeof(PermissionKind), permission);
        var hasPermission = userPermissions.Value.Has(permission);
        Response.Write(String.Format("<br>Permission: {0}, HasPermission: {1}", permissionName, hasPermission));
    }


}

Finally I realized that my SharePoint application is claims enabled. So I have to pass user-name in claims format.

string userName = @"i:0#.w|domain\username";

The code worked like a charm after that.

Hope this helps someone as I spent quite some time in figuring out this small thing. Its not mentioned anywhere in MSDN forums. I have tried to answer this on few posts in stack-exchange and stack-overflow forums.


12 December 2015

SharePoint - Error when configuring Federated Search (Open Search 1.0/1.1)

Recently I was trying to configure Federated Search on my SharePoint environment. I was configuring "Bing Search" as a Federated Result source.
(http://www.bing.com/search?q={?searchterms}&format=rss&Market=en-US).

After configuring it, when I tested the result source, I got following exception logged in SharePoint ULS logs -

SearchServiceApplication::Execute--Exception: System.ServiceModel.FaultException`1[System.ServiceModel.ExceptionDetail]: key is null or empty 

When I searched over internet, I came across Microsoft forum which mentions that this happens if your SharePoint installation has Sep 2014 update. This issue was fixed in Nov 2014 update.

I checked my SharePoint version and found that indeed I had Sep 2014 update only. It was not updated to Nov 2014 cumulative update. After performing the update, the issue got fixed.



09 December 2015

Introduction to Continuous Integration and Team City

Continuous Integration

Continuous Integration is a development practice that requires developers to integrate code into a shared repository on a regular basis (at least daily). Each integration process is verified by an automated build. Automated build may also include automated unit testing, code analysis etc. Automated build may be followed by automated deployment as well.

Advantages of Continuous Integration 

  • Takes code from central repository for build
  • Helps in detecting integration errors early & easily.
  • Leads to faster and more frequent integration.
  • Improves project management confidence.
  • Prevents last minute integration problems.


Disadvantages of Continuous Integration 
  • Extra cost requirement
  • Extra time/effort requirement

TeamCity:

TeamCity is Continuous Integration (CI) server from JetBrains. It provides all the features of Continuous Integration. It is available for Windows, Mac OS & Linux. 

Features of TeamCity:

  • Language & Platform support - It supports various language platform projects. E.g. – Java, .NET, Ruby, Xcode, C++, Python, PHP etc.
  • Integration with Source control systems - It supports various source control repositories.  E.g. – TFS, VSS, ClearCase, Subversion, Perforce, CVS etc.
  • Integration with build systems - It supports various build systems. E.g. – Java (Ant, Maven, Gradle), .NET (MSBuild, PowerShell, Nant), Ruby (Rake with RVM, Bundler, Ruby SDK).
  • Central Administration web console - Team city provides web based central administration console. It can be used for various activities like - administration, configuration & maintenance, managing projects & build configurations, Managing user accounts, groups & permissions, managing build agents, viewing various reports related to server etc.
  • Multiple build agents - Team city supports multiple build agents. Each build agent can run a build script. Hence TeamCity can run multiple parallel builds. Build jobs can be queued on build agents. The jobs will be executed once build agent is free. 
  • On the fly build progress reporting - TeamCity reports build progress (errors, warning, informational messages) as build progresses. Build progress is available on both web administration console and in IDEs. TeamCity alerts about failed tests immediately. 
  • Automated Unit Testing - TeamCity automatically runs unit test during build. The build fails if any test fails. Failed tests are highlighted in build results. Notifications can be sent for failed tests. Failed tests can also be assigned to specific developers leading to easier test management. Unit testing history and statistics is stored and available for analysis.
  • Code quality tracking – TeamCity provides various features for code quality tracking. E.g. – Duplicate code analysis, Static code analysis, Code coverage, Code quality reports etc.
  • Plugins – TeamCity supports plugins for extensibility. Over 100 ready to use plugins are freely available on TeamCity site. These plugins help in achieving functionalities which are not available out of the box. Users can develop their own plugins for any custom needs.

References and Suggested Readings:


05 December 2015

Useful websites for HTML5 and CSS3 browser compatibility check

I recently came across three useful websites for checking and verifying browser compatibility of various HTML5 and CSS3 features.

http://caniuse.com/ - This site lists various features of HTML5 and CSS3. When you click on any of the feature, it provides a list of browsers which supports these features along with their version number.

http://html5test.com/ - This site checks your browser for HTML5 feature compatibility and rate it on a pre-defined point scale. Then it provides a list of all features of HTML5 and their compatibility with your current browser. It also provides compatibility of various HTML5 features for other browsers.

http://css3test.com/ - This site checks your browser for CSS3 features compatibility and rate it on a percentage basis. It also provides a list of all features of CSS3 and their compatibility with your current browser.

Found these websites very useful during development and helps in deciding to use or not use a particular feature of HTML5 or CSS3.