Friday, February 24, 2012

Claims Based Authentication & Classic Mode Authentication in SharePoint 2010

When you are creating a new web application in SharePoint 2010, you will have to select one of these two authentication modes : Claims Based Authentication or Classic Mode Authentication.

Authentication

I was always selecting the first one not because I knew why I am selecting it, but because it's defaultly selected. So today I thought to learn about these two authentication modes and select the suitable one rather than just selecting the default option. I am writing down what I learned, so anyone who is doing the same thing like me can stop repeating it in the future.

SharePoint 2010 supports variety of authentication methods which will fall into various authentication method categories. Since I am no professional of these and these are some serious topics of their own, I will just write it this way.

Method category Authentication methods
Windows authentication NTLM
Kerberos
Anonymous
Basic
Digest
Forms-based authentication Lightweight Directory Access Protocol (LDAP)
Microsoft SQL Server database or other database
Custom or third-party membership and role providers
SAML token-based authenticationActive Directory Federation Services (AD FS) 2.0
Third-party identity provider
Lightweight Directory Access Protocol (LDAP)


In SharePoint 2010, authentication modes determine how client computers authenticate with it's resources. SharePoint 2010 supports these two authentication modes,
  1. Claims Based Authentication
  2. Classic Mode Authentication
Authentication is the process of determining whether someone or something is, in fact, who or what it is declared to be based on the user identity.In an Active Directory Domain Services (ADDS) installed environment user identity is based on a user account. You have a user account which will contain all the information of your user name, password, group membership information etc. To authenticate your account what the application would do is, it will match the information that you supplied with the information in the Active Directory.

The nice point is this. If you use Claims Based Authentication, you can use all the supported authentication methods listed in the above table. And if you use Classic Mode Authentication, you will only be able to use methods under Windows authentication category.

In Claims Based Authentication what will happen is, user obtains a security token that is digitally signed by a commonly trusted identity provider and contains a set of claims. Each claim represents a specific item of data about the user such as his or her name, group memberships, and role on the network. Claims-based authentication is user authentication that utilizes claims-based identity technologies and infrastructure. Applications that support claims-based authentication obtain the security token from the user and use the information within the claims to determine access to resources. No separate query to a directory service like ADDS is needed. Claims-based authentication in Windows is built on Windows Identity Foundation (WIF) which is a prerequisite to install SharePoint 2010.

In Classic Mode Authentication, user accounts are treated by SharePoint Server 2010 as Active Directory Domain Services (ADDS) accounts.

Hope you all got a good understanding about Claims Based Authentication & Classic Mode Authentication. Appreciate your feedback.

Happy Coding.

Regards,
Jaliya

Thursday, February 23, 2012

Decompiling a .NET dll

Today I wanted to decompile a .NET dll. While looking for a way of doing it, it got to my mind that some times back I had a trouble distinguishing "Decompile & Disassemble". Those days the both meant same to me and thought to write a brief explanation about this first.

The traditional explanation of these terms are as follows:
  1. Decompile - To convert assembly language to a high level language. 
  2. Disassemble - To convert machine language to assembly language.
Common Intermediate Language(CIL) is equivalent to assembly language for a CPU. In .NET, dll(Dynamic Link Library) is an assembly which is built up with the CIL code. Assembly is used for deployment, versioning, and security. There are two types of assemblies,
  1. Process assemblies (EXE)
  2. Library assemblies (DLL)
Now hope you all got a clear understanding about these two. So to decompile a .NET dll, I found out this nice open-source .NET assembly browser and decompiler.
     ILSpy

It has a lot of nice features,
  • Assembly browsing
  • IL Disassembly
  • Decompilation to C#
  • Saving of resources
  • Save decompiled assembly as .csproj
  • Search for types/methods/properties (substring)
  • Hyperlink-based type/method/property navigation
  • Base/Derived types navigation
  • Navigation history
  • BAML to XAML decompiler
  • Save Assembly as C# Project
  • Find usage of field/method
  • Extensible via plugins (MEF)

To get it to work, please remember that you need to have Microsoft .NET Framework 4 installed in your machine.

Happy Coding.

Regards,
Jaliya

Wednesday, February 22, 2012

ClickOnce for Google Chrome

Even though I am a big lover of Microsoft, I definitely don't love Internet Explorer. I love Google Chrome more, so the default browser for me is always Chrome. But have you ever had trouble running ClickOnce applications from Chrome?. Well I always had that trouble and what Chrome would do when clicked on ClickOnce applications is, it will download the Application Manifest. And then we click on Application Manifest, it will throw an error saying "Cannot download the application. The application is missing required files.Contact application vendor for assistance.".

Cannot Start Application

What I normally do in such situations is copy the link from Chrome and open the link with IE. IE will nicely run the ClickOnce application from the browser.

But sometimes this changing browser thing can be really painful. So thought to do some permanent fix and found out this nice little extension that will launch ClickOnce applications from Chrome.

You can add it to your chrome from foloowing link.
     ClickOnce for Google Chrome™.

It's weird that Chrome itself is installed with Microsoft's ClickOnce technology, but they don't support it in their browser themselves.

Happy Coding.

Regards,
Jaliya

Tuesday, February 14, 2012

Microsoft Business Intelligence(BI) Stack

"Business Intelligence" or "BI" is been one of the mostly discussing and most interesting topics in the industry these days. It is a very broad category of applications and technologies that is used to manipulate, discover and analyse data, so after reviewing those data people can take business decisions easily. Microsoft defines BI in the following way.

"Business intelligence (BI) simplifies information discovery and analysis, making it possible for decision-makers at all levels of an organization to more easily access, understand, analyze, collaborate, and act on information, anytime and anywhere."

Since today I am going to write about Microsoft BI Stack, I will try not to write more about BI, because it's a very large topic.

Microsoft first entered into BI market in the year of 1998 with OLAP(online analytical processing) Services in SQL Server 7.0. In 2000, Microsoft released SQL Server 2000. SQL Server 2000 is Microsoft's most significant release of SQL Server to date. With SQL Server 2000 Analysis Services, Microsoft started to touch the grounds of BI. Since first market entry, Microsoft was trying to make BI not only for the few business analysts and some executives but for everyone in the organization. And that's why Microsoft has integrated support for SQL Server Analysis Services(SSAS) into its Office products specially Microsoft Excel. Excel can be used as a SSAS client at a much lower cost than third-party client tools.

Following are the current Microsoft products that supports BI which are known as Microsoft BI Stack and all these things are very large areas which we should learn deeply.
  • SQL Server 2008 R2
  • SQL Server Analysis Services (SSAS)
  • SQL Server Integration Services (SSIS)
  • SQL Server Reporting Services (SSRS)
  • Data mining using SSAS
  • Excel
  • PowerPivot
  • SharePoint
  • Visio

Microsoft BI Stack

Hoping to write more about BI as I learn. Appreciate your feedback.

Happy Coding.

Regards,
Jaliya

Thursday, January 19, 2012

Tool to find the error message related to Correlation ID in SharePoint 2010

In SharePoint 2010 whenever you face an error, SharePoint will display a web page with a plain error message. That is "An unexpected error has occurred." and a Correlation ID.

An unexpected error has occurred

So have you ever wondered what is "Correlation ID" and I am pretty sure that Correlation ID will not make any sense to you.

So what is this Correlation ID? In SharePoint 2010, you get a Correlation ID (which is a GUID) attached to your logs/error messages when something happens. This ID can then be used to look up that specific error from the logs.

This Correlation ID is used per request-session in SharePoint 2010, and if you are in the process of requesting some information from SharePoint and bump into some problems along the way – your Correlation ID will be the best starting point for searching for what went wrong along that request.

With the help of SharePoint 2010 Management Shell, you can examine that specific Correlation ID and find out more information about it. Since I hate to open Management Shell and run some scripts every time I ran into these type of errors, I thought of writing a simple tool which will present me the error message details when I entered a Correlation ID.

Error Message From Correlation ID

What I did was pretty simple. I have created an simple Windows Application which will invoke the SharePoint 2010 Management Shell, run the script with a given Correlation ID and return the output. It's that much easy.

You all can try this simple tool your self.
     free download

We always develop tools for others and why not develop tools for our selves to make our life easy. Appreciate your feedback.

Happy Coding.

Regards,
Jaliya

Wednesday, January 18, 2012

Installed Microsoft SharePoint Server 2010 on Windows 7

Last week I have installed Microsoft SharePoint Foundation 2010 on Windows 7. For the last two days I was thinking why not give a try to install SharePoint Server 2010 and today I installed SharePoint Server 2010 Enterprise on my Windows 7.

I removed SharePoint Foundation 2010 and installed the SharePoint server. Installation went smoothly, and I was following the steps which was on my previous post about Installing Microsoft SharePoint Foundation 2010 on Windows 7.

SharePoint Server 2010 on Windows 7

Happy Coding.

Regards,
Jaliya

Friday, January 13, 2012

Installing Microsoft SharePoint Foundation 2010 on Windows 7

Since I am also working on Microsoft SharePoint Server and I am enjoying writing custom code for SharePoint, I always wanted to have some version of Microsoft SharePoint Server running in my physical computer. I have both Microsoft SharePoint Server 2010 and Microsoft SharePoint Foundation 2010 installed on two different virtual machines which has Microsoft Windows Server 2008 r2 running. So when I want to write some code on SharePoint, I had to switch on a virtual machine. Since my Dell has only 4GB of RAM, it takes a lot of time to switch on a virtual machine and I am lacking patience.

So I thought of installing Microsoft SharePoint Foundation 2010 on my Windows 7 Ultimate which has Microsoft SQL Server 2008 R2 already installed. First I thought it will be a easy thing, but trust me it's not sweet as it seems. So I am going to write down some few things which I am sure you will find helpful.

First thing is we need to do some changes to SharePointFoundation.exe before running it. Because when you download and run the SharePointFoundation.exe, you will see this setup error message.

Setup Error
To avoid this error, we need to modify the SharePointFoundation.exe. Let's say I have copied my initial SharePointFoundation.exe file to"C:\MySharePointFiles". We can do this by extracting the exe and changing the installation configuration file which will be in "c:\MySharePointFiles\files\Setup\config.xml".

To extract the exe, in your command prompt type,
c:\SharePointFiles\SharePointFoundation.exe /extract:c:\MySharePointFiles
Add this line inside the <configuration> tag in config.xml.
<Setting Id="AllowWindowsClientInstall" Value="True"/>
Now you will not face any setup error. Next thing to notice is when you run PrerequisiteInstaller.exe, it will say this message which is "This tool does not support the current operating system.". So we will have to install the prerequisites manually if you don't already have them.

After installing prerequisites and installing SharePoint Foundation, I started configuration wizard. I have selected "Server Farm" and selected "Complete" as my Server Type. Then after filling out next screens and when I started configuration, I got an error saying I am trying to start configuration with an local user account. It's a pretty clean error message, because I am trying to make an installation on my Windows 7 which has no Active Directory.

But there is a workaround for this problem. That is with the help of SharePoint 2010 Management Shell which was installed during SharePoint Foundation installation. Open SharePoint 2010 Management Shell and run the New-SPConfigurationDatabase command with the appropriate parameters.
New-SPConfigurationDatabase -DatabaseName "SharePoint2010_Config" -DatabaseServer "Ravana" -AdministrationContentDatabaseName "SharePoint2010_Admin_Content" -Passphrase (ConvertTo-SecureString "P@ssw0rd" -AsPlaintext -Force) -FarmCredentials (Get-Credential)
This command will prompt you a Window PowerShell Credential Request to enter your username and password. Make sure to enter the username as "computername\username". Then  I got this error,
New-SPConfigurationDatabase : Could not load file or assembly 'Microsoft.Identi
tyModel, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or
one of its dependencies. The system cannot find the file specified.
At line:1 char:28
+ New-SPConfigurationDatabase <<<<  -DatabaseName "SharePoint2010_Config" -Data
baseServer "Ravana" -AdministrationContentDatabaseName "SharePoint2010_Admin_Co
ntent" -Passphrase (ConvertTo-SecureString "P@ssw0rd" -AsPlaintext -Force) -Far
mCredentials (Get-Credential)
    + CategoryInfo          : InvalidData: (Microsoft.Share...urationDatabase:
   SPCmdletNewSPConfigurationDatabase) [New-SPConfigurationDatabase], FileNot
  FoundException
    + FullyQualifiedErrorId : Microsoft.SharePoint.PowerShell.SPCmdletNewSPCon
   figurationDatabase
It says it can't load the assembly "Microsoft.IdentityModel". I examined my assembly directory which is "C:\Windows\assembly". Microsoft.IdentityModel assembly was already there. Then what I did was pretty simple. I removed the Windows Identity Foundation I already had and installed the appropriate file I got downloaded from following link and restarted the machine.
     Download Windows Identity Foundation

Now again I ran the above SharePoint 2010 Management Shell command, and now the command got completed successfully. Then I started the configuration wizard again and this time it went smoothly and completed.

After successful configuration, I thought of creating a new web application from my SharePoint 2010 Central Administration. When I went to Manage Web Applications page and for my surprise "New" in the ribbon was disabled. I ran my browser as administrator and it was still disabled. To fix this what I did was "changing user account control settings to never". You can do that by going through,
control panel->user accounts->change user account control settings->never 
And now everything was perfectly working. Hope you found this post helpful. Appreciate your feedback.

Happy Coding.

Regards,
Jaliya

Thursday, January 12, 2012

Microsoft SQL Server 2012

Today I am going to write my first post in this year and it's about Microsoft SQL Server code name 'Denali'. Microsoft has released SQL Server 2012 RC0.

I am pretty sure you must be wondering what is RC0. RC0 stands for 'Release Candidate 0'. The term release candidate (RC) refers to a version with potential to be a final product, which is ready to release unless fatal bugs emerge. In this stage of product stabilization, all product features have been designed, coded and tested through one or more beta cycles with no known showstopper-class bug.

So Microsoft has made available a release candidate of Microsoft SQL Server 2012, considering it "production ready". Microsoft referred this new version as SQL Server Code Named "Denali", but has settled on SQL Server 2012 as the final name for the product.

There are many new features in this release throughout all components, including the Database Engine, the Analysis, Integration, Reporting and Master Data Services, but the SQL Server Team Blog has outlined 5 of them considered as most important:
  • Greater availability : Deliver the required 9s and data protection with AlwaysOn, delivering added functionality over CTP3 that allows customers to experience multiple, readable secondaries for distributed scale of reporting and backup workloads and support for FileTable and FILESTREAM which brings first-class HA to complex data types.
  • Blazing-fast performance  :  More effectively govern performance in multi-tenancy environments like private cloud. Resource Governor enhancements include support for 64 resource pools, greater CPU usage control, and resource pool affinity for partitioning of physical resources and predictable resource allocation.
  • Rapid data exploration  :  Empower end users with new insights through rapid data exploration and visualization. Discover new insights at the speed of thought with more feature/functionality in Power View, the highly interactive, familiar browser-based data exploration, visualization, and presentation experience for end users.
  • Credible, consistent data  :  In addition to CTP3 functionality delivered for Data Quality Services and Master Data Services, customers can better support heterogeneous data within Data Warehouses through new Change Data Capture (CDC) support for Oracle.
  • Optimized productivity  :  Optimize IT and developer productivity across server and cloud with the new SQL Server Data Tools, a unified development experience for database and business intelligence projects, and cloud-ready capabilities within SQL Server Management Studio for snapshot backups to the Windows Azure Platform. Additionally, SQL Server 2012 offers a new version of Express – LocalDB. SQL Express LocalDB is a lightweight version of Express with all its programmability features, yet runs in user mode with a fast, zero-configuration installation and short list of pre-requisites.

The product will come in 3 main editions: Standard, Business Intelligence and Enterprise. Here is a feature comparison among the three main editions.

Feature comparison - SQL Server 2012 Editions

For more information,
     Microsoft SQL Server 2012
     What's New in SQL Server 2012 RC 0
     SQL Server 2012 Editions

Happy Coding.

Regards,
Jaliya

Thursday, December 29, 2011

How Does the Garbage Collector Work in .NET

While you are doing application programming and when you are creating objects of classes, have you ever wondered, in the end what will happen to all these objects you have created. Well I have always wondered and today I am going to write about this nice mechanism called Garbage Collection which is responsible for proper resource management in .NET.

Every object that you create has a life cycle, from creation to destruction. When an object is destroyed, its state must be cleaned, and any managed resources used must be reclaimed. And that's where the Garbage Collector comes in. Garbage collection in the Microsoft .NET common language runtime environment, completely absolves the developer from tracking memory usage and knowing when to free memory.

Implementing a proper resource management mechanism by us for our own applications would be a difficult and time taking task. It will surely distract our concentration on the real problems that we are going to solve. Garbage Collector will take all the trouble of doing the resource management, so we will only have to focus our minds on our real problem.

So as I have mentioned before, every object that we create has a life cycle.
  1. First, block of memory will be allocated and that block of memory is big enough to hold the object.
  2. Then by calling the constructor we initialize the object. Now memory will be converted into an object.
  3. Object can be then used by our application.
  4. Object will then arranged for clean up.
  5. After the cleaning up is completed, the allocated memory for that particular object is reclaimed.
From above things, we can only control the second step and the fourth step. We call the constructor for the second step and we can implement and call the destructor for the fourth step.

So How Does the Garbage Collector Work

The garbage collector runs in its own thread and normally runs automatically, under well defined circumstances. When the garbage collector runs, other threads in an application are halted because the garbage collector may move objects in memory and must update pointers to the correct addresses for these objects.

The steps that the garbage collector would take to reclaim resources are as follows.
  1. It marks every object as dead; objects are considered dead unless proved otherwise.
  2. It starts from objects referenced on the stack, marking referenced objects as alive. It performs this recursively; if an object that is already marked as alive references another object, that object is also marked as alive. The garbage collector includes logic to prevent infinite recursion, for example, where there is a circular reference between two objects.
  3. It checks whether any of the objects that have been marked as dead have a destructor that must be run. Running the destructor is referred to as finalization. Any objects that require finalization are moved to a data structure maintained by the garbage collector called the freachable queue. The freachable queue stores pointers to objects that require finalization before their resources can be reclaimed.
  4. Objects added to the freachable queue are marked as alive because there is now a valid reference to them; the destructor must be run before their memory can be reclaimed. Objects are normally added to the freachable queue only once.
  5. Objects marked as alive are moved down the heap to form a contiguous block, defragmenting the heap. References to objects (on the stack and in other objects on the heap) moved by the garbage collector are updated.
  6. Other threads resume.
  7. On a separate thread, objects added to the freachable queue are finalized. After an object is finalized, the pointer to that object is removed from the freachable queue. Objects are not removed from memory until the next time the garbage collector runs.
So that's how the garbage collector works in .NET framework. Please feel free to give me your valuable feedback.

Happy Coding.

Regards,
Jaliya

Tuesday, December 6, 2011

Mono for Android 4.0 is Here.

Xamarin has announced the release of its Mono open-source .NET development platform for Android 4.0. This release supports all the new features introduced in Android 4.0 which is code named as "Ice Cream Sandwich". Mono for Android 4.0 comes with a VS plug-in, incremental build, incremental deployment, installer with all packages needed, Google Maps integration, and support for Java 7.

The new features that are introduced with this release are,
  1. An incremental builder which is reducing build times by 40%
  2. Incremental deployment support reducing the deployment time “from minutes to seconds”
  3. An installer that packages together all the pieces necessary for Android development on Mono: JDK, Android SDK, GTK#, MonoDevelop and Mono for Android
  4. Google Maps integration - Integrate Google Map functionality into your apps easier than ever before with newly bound APIs.
  5. Java 7 support
So why not try it out guys. If you already have Mono for Android, simply launch MonoDevelop and you will be prompted to update. If you're using Visual Studio then you can download and install the update manually from the following link.

Happy Coding.

Regards,
Jaliya