Tools

Enable app sideloading in SharePoint Online

To be able to deploy solutions from Visual Studio to SharePoint Online, the SideLoading feature must be enabled on your site.

Install and configure SharePoint Online Management Shell

If you haven’t already done so, you can download SharePoint Online Management Shell and install it. If you are running this a client machine like Windows 8, you might have to change the script execution policy. To be sure, type the following command

Get-ExecutionPolicy -List

If the ExecutionPolicy of CurrentUser scope is shown as Undefined then this means your policy is set as Restricted and you will not be able to execute scripts. To read more about the various types of execution policies, visit http://go.microsoft.com/fwlink/?LinkID=135170. Usually the RemoteSigned policy is good enough so type the following command

Set-ExecutionPolicy RemoteSigned -Scope CurrentUser

Enabling Siteloading on your site

When you are prompted for your site URL, remember to use HTTPS prefix otherwise you will get a 403 Forbidden error.

#CODE STARTS HERE
$programFiles = [environment]::getfolderpath("programfiles")
add-type -Path $programFiles'\SharePoint Online Management Shell\Microsoft.Online.SharePoint.PowerShell\Microsoft.SharePoint.Client.dll'
Write-Host 'Ready to enable Sideloading'
$siteurl = Read-Host 'Site Url'
$username = Read-Host "User Name"
$password = Read-Host -AsSecureString 'Password'

$outfilepath = $siteurl -replace ':', '_' -replace '/', '_'

try
{
[Microsoft.SharePoint.Client.ClientContext]$cc = New-Object Microsoft.SharePoint.Client.ClientContext($siteurl)
[Microsoft.SharePoint.Client.SharePointOnlineCredentials]$spocreds = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($username, $password)
$cc.Credentials = $spocreds
$site = $cc.Site;

$sideLoadingGuid = new-object System.Guid "AE3A1339-61F5-4f8f-81A7-ABD2DA956A7D"
$site.Features.Add($sideLoadingGuid, $true, [Microsoft.SharePoint.Client.FeatureDefinitionScope]::None);

$cc.ExecuteQuery();

Write-Host -ForegroundColor Green 'SideLoading feature enabled on site' $siteurl
#Activate the Developer Site feature
}
catch
{
Write-Host -ForegroundColor Red 'Error encountered when trying to enable SideLoading feature' $siteurl, ':' $Error[0].ToString();
}

#CODE ENDS HERE

That’s it. You will now be able to deploy your solutions from Visual Studio.

Share

Configuring SharePoint 2010 User Profiles using AD LDS in Windows 8

Recently I published a series of three articles that provided an in-depth visual guide on how to configure SharePoint User Profiles in a Windows 8 development environment using Active Directory Lightweight Directory Services.

Part 1: Installing & Configuring AD LDS

Part 2: Configuring a web application using Forms Based Authentication and connecting it to AD LDS

Part 3: Importing user profiles from AD LDS

I hope these articles will help developers out there to get the flavor of Active Directory in their development environment without the extra luggage.

Happy SharePointing!

Share

Configuring SharePoint 2010 User Profiles using AD LDS in Windows 8 – Part 3

In Part 2 of this series we configured a web application with FBA and connected it to AD LDS. This post will be a short one as the steps are very simple and self explanatory.

Navigate to Central Administration –> Application Management –> Manage Service Applications. Select the User Profile Service Application and click on Administrators from the ribbon. Add the sp_ups_svc account and provide it Full Control.

2013-02-23 14_01_08-Manage Service Applications

 

SharePoint provides no native method to import profiles from AD LDS. Instead, the only option out of the box is an LDIF import. Download the SharePoint AD LDS Synchronization Solution and follow the documentation. Once your profile import is complete, you will be able to see your profile from your My Profile page.

2013-02-23 14_26_11-SharePoint User 1

Now you can access these profile properties from your code and even InfoPath.

 

Happy SharePointing!

Share

Configuring SharePoint 2010 User Profiles using AD LDS in Windows 8 – Part 2

In Part 1 of this series we looked at how to install and configure AD LDS on a Windows 8 client. In this post I will be deploying a web application in SharePoint with FBA using AD LDS as the authentication provider.

 

Configuring a SharePoint web application with FBA

First, we have to register the Windows account sp_ups_svc which we created in Part 1 as a managed account and we have to create a new Windows account called sp_farm and register that as well. Fire up Internet Explorer as an administrator and navigate to your Central Administrator; If you skip this step, you will find many features in the Central Administration are disabled.

 

2013-02-23 10_54_45-

 

Navigate to Security –> General Security –> Configure Managed Accounts and add the Windows account.

 

2013-02-23 11_10_06-Managed Accounts

 

Navigate to Security –> General Security –> Configure service accounts and assign this account for the User Profile Synchronization Service.

 

2013-02-23 11_14_53-Service Accounts

 

Now create a web application with the following settings:

2013-02-23 11_20_54-Web Applications Management 2013-02-23 11_22_02-Web Applications Management

Please note that I selected sp_farm as the account for the application pool – this is very important. Once the web application has been created, create a top level site collection and assign the currently logged in Windows account as the primary site collection administrator.

2013-02-23 11_22_41-Web Applications Management

 

Next create another site collection under this site collection using the My Sites template which we will later use to host My Sites and My Profile page.

 

2013-02-23 11_31_59-Create Site Collection

 

Navigate to Application Management –> Manage Service Applications and click on your User Profile Service Application. Under My Site Settings, click on Configure Trusted Host Locations and add the new site collection we just created for My Site.

2013-02-23 11_35_40-Add Trusted Host Location

 

Configure AD LDS with FBA

 

This is the part where we tie up FBA with AD LDS. We just need to make a few modifications to the web.config files of the new web application, central administration and the Security Token Service. Make sure to make a backup before you modify them.

Web application:

<PeoplePickerWildcards>
	<clear />
	<add key="AspNetSqlMembershipProvider" value="%" />
	<add key="TechOneGlobalMember" value="*" />
     </PeoplePickerWildcards>
     
     <membership defaultProvider="i">
	<providers>
		<add name="i" type="Microsoft.SharePoint.Administration.Claims.SPClaimsAuthMembershipProvider, Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" />
		<add name="TechOneGlobalMember" type="Microsoft.Office.Server.Security.LdapMembershipProvider, Microsoft.Office.Server, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" server="RaihanIqbal" port="50000" useSSL="false" userDNAttribute="distinguishedName" userNameAttribute="userPrincipalName" userContainer="CN=SharePoint2010,DC=TechOneGlobal,DC=local" userObjectClass="user" userFilter="(ObjectClass=user)" scope="Subtree" otherRequiredUserAttributes="sn,givenname,cn" />
	</providers>
     </membership>
     <roleManager defaultProvider="c" enabled="true" cacheRolesInCookie="false">
	<providers>
		<add name="c" type="Microsoft.SharePoint.Administration.Claims.SPClaimsAuthRoleProvider, Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" />
		<add name="TechOneGlobalRole" type="Microsoft.Office.Server.Security.LdapRoleProvider, Microsoft.Office.Server, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" server="RaihanIqbal" port="50000" useSSL="false" groupContainer="CN=SharePoint2010,DC=TechOneGlobal,DC=local" groupNameAttribute="cn" groupNameAlternateSearchAttribute="cn" groupMemberAttribute="member" userNameAttribute="userPrincipalName" dnAttribute="distinguishedName" userFilter="&(objectClass=user)(objectCategory=person)" groupFilter="&(objectCategory=Group)(objectClass=group)" scope="Subtree" />
	</providers>
     </roleManager>

Central Administration:

<PeoplePickerWildcards>
	<clear />
	<add key="AspNetSqlMembershipProvider" value="%" />
	<add key="TechOneGlobalMember" value="*" />
    </PeoplePickerWildcards>
    
    <roleManager enabled="true" defaultProvider="AspNetWindowsTokenRoleProvider">
	<providers>
		<add name="TechOneGlobalRole" type="Microsoft.Office.Server.Security.LdapRoleProvider, Microsoft.Office.Server, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" server="RaihanIqbal" port="50000" useSSL="false" enableSearchMethods="true" groupContainer="CN=SharePoint2010,DC=TechOneGlobal,DC=local" groupNameAttribute="cn" groupNameAlternateSearchAttribute="cn" groupMemberAttribute="member" userNameAttribute="userPrincipalName" dnAttribute="distinguishedName" scope="Subtree" userFilter="&(objectClass=user)(objectCategory=person)" groupFilter="&(objectCategory=Group)(objectClass=group)" />
	</providers>
    </roleManager>
    <membership>
	<providers>
		<add name="TechOneGlobalMember" type="Microsoft.Office.Server.Security.LdapMembershipProvider, Microsoft.Office.Server, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" server="RaihanIqbal" port="50000" useSSL="false" enableSearchMethods="true" userDNAttribute="distinguishedName" userNameAttribute="userPrincipalName" userContainer="CN=SharePoint2010,DC=TechOneGlobal,DC=local" userObjectClass="user" userFilter="(ObjectClass=*)" scope="Subtree" otherRequiredUserAttributes="sn,givenname,cn" />
	</providers>
    </membership>

Security Token Service (C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\WebServices\SecurityToken):

<system.web>
	<membership>
		<providers>
			<add name="TechOneGlobalMember"
                  type="Microsoft.Office.Server.Security.LdapMembershipProvider, Microsoft.Office.Server, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c"
                  server="RaihanIqbal"
                  port="50000"
                  useSSL="false"
                  enableSearchMethods="true" 
                  userDNAttribute="distinguishedName"
                  userNameAttribute="userPrincipalName"
                  userContainer="CN=SharePoint2010,DC=TechOneGlobal,DC=local"
                  userObjectClass="user"
                  userFilter="(ObjectClass=*)"
                  scope="Subtree"
                  otherRequiredUserAttributes="sn,givenname,cn" />
		</providers>
	</membership>
	<roleManager enabled="true">
		<providers>
			<add name="TechOneGlobalRole"
                  type="Microsoft.Office.Server.Security.LdapRoleProvider, Microsoft.Office.Server, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c"
                  server="RaihanIqbal"
                  port="50000"
                  useSSL="false"
                  enableSearchMethods="true" 
                  groupContainer="CN=SharePoint2010,DC=TechOneGlobal,DC=local"
                  groupNameAttribute="cn"
                  groupNameAlternateSearchAttribute="cn"
                  groupMemberAttribute="member"
                  userNameAttribute="userPrincipalName"
                  dnAttribute="distinguishedName"
                  userFilter="&(objectClass=user)(objectCategory=person)"
                  groupFilter="&(objectCategory=Group)(objectClass=group)"
                  scope="Subtree" />
		</providers>
	</roleManager>
</system.web>

We are almost there! Restart IIS using the command iisreset and navigate to the web application. You should now be able to login using Forms Authentication with the user account you created in AD LDS.

 

2013-02-23 12_38_43-Sign In

 

In Part 3 we will import the user profiles using the User Profile Service Application.

Share

Configuring SharePoint 2010 User Profiles using AD LDS in Windows 8 – Part 1

If you have a SharePoint 2010 development environment setup in Windows 8 but you don’t have Active Directory you can still configure User Profiles in your SharePoint server. The process is very painstaking so get a cup of coffee, roll up your sleeves and read with full attention!

 

Installing and configuring AD LDS

 

From the Windows features list, turn on Active Directory Lightweight Directory Services.

 

2013-02-22 19_12_36-Windows Features

 

Before we proceed with the installation, we will need to create a couple of Windows accounts as we will be needing them later. Remember to uncheck “User must change password at next logon” and check “Password never expires”.

 

2013-02-22 19_53_34-Computer Management

 

Once the installation is done, navigate to Administrative Tools and run the setup wizard.

 

2013-02-22 19_15_10-Administrative Tools

 

Click Next to begin the installation of AD LDS. We will have to create a unique instance since we do not have an instance created.

 

2013-02-22 19_23_23-Active Directory Lightweight Directory Services Setup Wizard

 

We will have to provide a unique name for the instance and this name cannot contain any spaces.

 

2013-02-22 19_25_47-Active Directory Lightweight Directory Services Setup Wizard

 

The LDAP and SSL port number must be available and not used by any other application. Take a note of these port numbers because we will need them later.

 

2013-02-22 19_29_44-Active Directory Lightweight Directory Services Setup Wizard

 

Create an application directory partition with a proper partition name and then proceed to specify the locations to store the data.

 

2013-02-22 19_35_31-Active Directory Lightweight Directory Services Setup Wizard

 

Instead of using the default Network Service account, we will use one of the user accounts that we created earlier. When you click Next, you are prompted to run the account as a service, click Yes.

 

2013-02-22 19_57_37-Active Directory Lightweight Directory Services Setup Wizard

 

If you are logged in as the administrator, you can keep the default selection as the AD LDS Administrator otherwise you will have to specify an account with administrative privileges.

 

2013-02-22 20_08_36-Active Directory Lightweight Directory Services Setup Wizard

 

The last step is to decide which LDIF files to import. For SharePoint, and for AD LDS replication, we have to import the following files:

 

2013-02-22 20_11_00-Active Directory Lightweight Directory Services Setup Wizard

 

Once the setup is complete, fire the ADSI editor using the command adsiedit.msc. In the left panel, right click on ADSI Edit and select Connect To. Provide a friendly name for the connection and under Connection Point type in the partition name which we created earlier during the installation. Under Computer type in the server name in the format Full_Computer_Name:LDS_Port. If you’re unsure about the full computer name, right click on My Computer to get it.

 

2013-02-22 20_15_17-Configuring SharePoint 2010 User Profiles using AD LDS in Windows 8 – Part 1 - W

 

Click once on the connection name and then the naming container to get the following structure.

 

2013-02-22 20_25_20-ADSI Edit

 

Right click on the container and create a new object of class type container with the value User.

 

2013-02-22 20_30_18-Create Object

 

Under the User container, we will add our SharePoint users. Right click on the User container, and create a new object of class User and enter the full name of the user. In my case its “SharePoint Test User 1”. Right click on the user and select Reset Password.

 

2013-02-22 20_34_45-ADSI Edit

 

Now we need set certain properties for the user which will be later imported into SharePoint User Profile. I suggest the following properties be updated with appropriate values:

  • displayName: SharePoint Test User 1
  • department: Information Technology
  • msDS-UserAccountDisabled: FALSE
  • msDS-UserDontExpirePassword: TRUE
  • msDS-UserPasswordNotRequired: FALSE
  • telephoneNumber: 01710000000
  • title: Software Engineer
  • userPrincipalName: sp1 (Cannot contain spaces)

 

2013-02-22 20_49_44-CN=SharePoint Test User 1 Properties

 

Similarly, you can add other users as needed. Click on the Roles container and edit the member property of the Reader role. Add the second Windows account that we created earlier here. Remember to hit Apply in the properties dialogue.

 

2013-02-22 20_54_20-Multi-valued Distinguished Name With Security Principal Editor

 

Congratulations! Your AD LDS is now ready to be used with SharePoint! In Part 2 of this series we will create a new web application and configure Forms Based Authentication and connect it to AD LDS.

Share

ASP.NET Web Site Administration Tool (WAT) Error

Those of us who use the ASP.NET WAT on a regular basis must have encountered this error at least once.

An error was encountered. Please return to the previous page and try again.

WAT_Error 

After some research I found out that the tool doesn’t work if you have spaces in the path of your applications directory for e.g. D:\My Stuff\Projects\Project1. I know, it’s weird!

The Solution

If you don’t want to go through the hassle of moving your project folders, worry not, NTFS Link comes to the rescue. Once you’ve downloaded and installed the tool, right click at a location of your choice and select New Junction Point.

New_Hard_Link

You will then be prompted to select the target folder. In our case, this should point to D:\My Stuff\ since that is the folder that contains a space in its name.

New_Shortcut

Once the shortcut is created you can rename it to something without a space so our final path would be something like D:\ProjectsLink\Projects\Project1. The WAT tool should work now.

Share

Visual Studio 2010 Unicode Bangla Font Support Issues

One fine day my Visual Studio 2010 couldn’t render Bangla fonts and all I saw were square boxes as you see below.

VS2010_NoBanglaFont

After banging my head for hours, I realized I had upgraded my Avro Keyboard after the last time I used VS2010 and during the installation I was prompted to change my default Bangla font from Vrinda to Siyam Rupali.

AvroFontChange

Little did I know that VS2010 only supports Vrinda to render Bangla in the text editor so I went ahead and changed my default font – bummer!! Luckily, I found a tool called Font Fixer which can restore your systems default Bangla font.

FontFixer_Rupali

As you can see, my default font was set to Siyam Rupali. I clicked on Restore which then prompted me to install the Vrinda fonts manually (from my backup) and restart my computer. After booting up, I ran the tool again to confirm if the font was reset to Vrinda.

FontFixer_Vrinda

Now Bangla is being properly rendered in VS2010 and I’m one happy Bengali coder Smile

VS2010_Bangla

I’m not sure if Microsoft is aware of this issue but they need to make Visual Studio compatible with any unicode Bangla font and not just Vrinda.

Share

HTML5 Support In Visual Studio 2010

I was trying to play around with HTML5 assuming that VS 2010 had shipped with HTML5 support but to my dismay it was not the case. Bummer! So I did a bit of homework and came up with an easy workaround. If you try googling for html5 visual studio 2010, the first link that you will see is HTML 5 Intellisense for Visual Studio 2010 and 2008. But unfortunately, the patch provided over there doesn’t seem to work. (DO I HAVE TO DO EVERYTHING!!)

So here’s how I got it to work.

  1. Download this archive and extract the contents to your desktop.
  2. Copy/Move html_5.xsd to D:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\Packages\schemas\html. The path may vary depending on where you installed VS 2010 or Visual Web Developer 2010. vs2010folder
  3. From the extracted contents, run the appropriate registry file. In my case, it was VS-2010-x64.reg
  4. Now fire up Visual Studio 2010 (or VWD) and navigate to Tools > Options > Text Editor HTML > Validation. On the right panel, select HTML 5 as the Target. vs2010ValOption
  5. Now restart VS 2010 and you should be able to code valid HTML5. Enjoy! vs2010html5demo
Share

Discovering MSBuild – Part One

Background

This series is all about me trying to learn the dark art of MSBuild. Ever since I started developing .NET applications, I was aware of the existence of this strange tool but I could never harness its true potential. So lets begin our adventure!

Introduction

An MSBuild file typically known as an MSBuild Project File contains instructions on how to build your application step by step – neat stuff! This innovative tool from Microsoft helps you to take control over every aspect of the build process thereby helping you to automate the build and deployment process.

Overview

An MSBuild project file is basically an XML file. This XML document is defined by two XSD documents Microsoft.Build.CommonTypes.xsd and Microsoft.Buid.Core.xsd. Both these files are located in the %WINDIR%\Microsoft.NET\Framework\vXXXX\MSBuild folder. The basic structure of an MSBuild project file looks like this:

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
</Project>

This structure is comprised of Properties, Items, Targets. Confused? You should be. 😉 Put it simply, items are the files that are going to be built and properties are the build parameters ex. Configuration or OutputPath.

Project Properties

Properties are nothing but Key-Value pairs and apparently there two different types of Properties – Static, Dynamic. What I know about static properties is that they must be contained within a PropertyGroup element which is declared directly under the project element. A project element may contain multiple PropertyGroup elements.

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
    <PropertyGroup>
        <ApplicationName>MyDemoApp</ApplicationName>
        <WhyAmICrazy>I Have No Idea</WhyAmICrazy>
    </PropertyGroup>
</Project>

In the above example, ApplicationName is the key and MyDemoApp is the value(DUH!!). Can values contain spaces? I have no idea – so lets find out. Paste the above code in notepad and save it with a *.proj extension, fire up the Visual Studio Command Prompt, and execute the script.

Noname

Oppsss! Look’s like we are missing something called Targets? Not to worry, let’s dig deeper.

Tasks & Targets

Targets are the work horses of the MSBuild file so without them the file would be literally useless. Properties are utilized within these targets. A task is the smallest unit of work and a target is a sequential set of tasks. The MSBuild tool ships with a predefined set of tasks like Copy, Csc(wow haven’t used this baby in a while!), Move, Exec, etc. Tasks are invoked using parameters which are just XML attributes with values. The attributes may vary from task to task. For our example we will try out the Message task.

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
    <PropertyGroup>
        <ApplicationName>MyDemoApp</ApplicationName>
        <WhyAmICrazy>I Have No Idea</WhyAmICrazy>
    </PropertyGroup>
    <Target Name="HelloWorld">
        <Message Text="This is my first MSBuild Application" />
    </Target>
</Project>

To build this project the command should be of the format

msbuild FILE_NAME /t:TARGET_NAME

For our example the command would look like

msbuild Sample1.proj /t:HelloWorld

You will see that the build succeeds without any errors! We may have won the battle but not the war 😉

A more complicated example for you adrenaline junkies out there:

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
    <PropertyGroup>
        <ApplicationName>MyDemoApp</ApplicationName>
        <WhyAmICrazy>I Have No Idea</WhyAmICrazy>
    </PropertyGroup>
    <Target Name="HelloWorld">
        <Message Text="This is my first MSBuild Application and $(WhyAmICrazy) why I love .NET" />
    </Target>
</Project>

 

Until the next episode..

Share