Pages

Sunday, June 23, 2013

SharePoint Server 2013, Active Directory Groups and the access denied problem caused by token lifetime.

A while ago we experienced some issues when using Active Directory groups and SharePoint Server 2013. We added users to Active Directory groups which were added to SharePoint groups, but the users who got access using this method, still got access denied. After some investigation we found the problem.

In SharePoint 2013 all authentication is being handled through claims which are managed by the Security Token Service (STS). The STS is responsible for issuing security tokens to users. A user which has logged on to SharePoint will be authenticated and granted a token with his group membership. These tokens have a certain lifetime and will not be updated until they expire. The property which controls this is the WindowsTokenLifetime property – according to the documentation is it normally set to 1380 minutes or 23 hours -  see Set-SPSecurityTokenServiceConfig for more details. (On one of my SharePoint 2013 it seemed to be 10 hours).

Therefore users who had already logged on to the SharePoint Server did not get the required tokens for their new AD group membership until the token expired. You can however change the token expiration in the following way:

$sts = Get-SPSecurityTokenServiceConfig
$sts.WindowsTokenLifetime = (New-TimeSpan -Minutes 15)
$sts.LogonTokenCacheExpirationWindow = (New-TimeSpan -Minutes 15)
$sts.Update()

Changing the WindowsTokenLifeTime will probably have a performance impact since there will be a lot more requests going from the STS to your Active Directory domain controllers. I haven’t found clear guidance or best practices about this, so feel free to leave a comment.

Tuesday, June 11, 2013

Quick tip - copying files from your host to Hyper-V guest

I have been working with VMWare for quite a while but recently switched to Hyper-V on my Windows 8 portable. One thing I’m still struggling with is the ability to easily copy files from my host OS (Windows 8) to my guest OS which is running in Hyper-V. Currently I’m using Folder2Iso to quickly create ISO files which I then mount in my Hyper-V environment. If anyone knows of a better way of doing this – please leave a comment.

SharePoint Service Applications: SharePoint 2013 versus 2010

Service Applications Description SPS 2010 Std SPS
2010 Ent
SPS
2013 Std
SPS 2013 Ent
Access Services Let’s user view, edit and interact with Access 2010 databases which are published to SharePoint in a web browser

X

X

App Management service Provides administrators the ability to manage new SharePoint apps. Apps can be purchased from an external vendor or developed internally. It checks user access permissions and licensing for app usage.    

X

X

Application Discovery and Load Balancer service A.k.a. Topology web service. SharePoint has a built in basic load balancer  that provides administrator with fault-tolerant out of the box SharePoint service applications. See SharePoint 2010 Service Application Load Balancer for more details.

X

X

X

X

Business Data Connectivity service Gives access to line-of-business data systems – also check out the Business Connectivity Services code samples for SharePoint 2013

X

X

X

X

Excel Services Application Let’s users view and interact with Excel files in a web browser

X

 

X

Machine Translation service Provides automatic translation of sites and files (See Machine Translation Services in SharePoint 2013 for more details)    

X

X

Managed Metadata service Manages taxonomy hierarchies,keywords and social tagging infrastructure, and publish content types across site collections

X

X

X

X

Office Web Apps Service Office Web Apps is now a separate product, rather than a SharePoint Service Application. See Use Office Web Apps with SharePoint Server 2013 for more details.        
PerformancePoint Service Application Let’s users create dashboards and balanced scorecards  

X

X

PowerPoint Automation service Performs automated bulk PowerPoint conversions to other formats (pptx,pdf,xps,jpg,png) (See PowerPoint Automation Services in SharePoint  2013 for more details)    

X

X

Search service Crawls content, produces index partitions and serves search queries

X

X

X

X

Secure Store service Provides single sign on authentication to access multiple applications or services

X

X

X

X

State service Provide temporary storage of user session data for SharePoint Server components

X

X

X

X

Usage and Health Data Collection service Collects farm wide usage and health data and provides the ability to view various usage and health reports

X

X

X

X

User Profile service Adds support for My Site sites, profile pages, social tagging and other social computing features

X

X

X

X

Visio Graphics service Let’s users view and refresh published Visio diagrams in a web browser  

X

 

X

Web Analytics service Collect, reports, and analyzes the usage of SharePoint Server sites. The functionality of the Web Analytics service has been incorporated into the Search service

X

X

   
Work Management service Enables users to synchronize and aggregate tasks between different Microsoft products such as Exchange, SharePoint and Project Server. See Configure Exchange task synchronization in SharePoint Server 2013 for practical details or the My Tasks aggregation in SharePoint Server and Exchange Task integration white paper    

X

X

Word Automation service Performs automated bulk document conversions.

X

X

X

X

Subscription Settings Service Provides multi-tenant functionality for service applications. Tracks subscription IDs and settings for services that are deployed in partitioned mode. Deployed through Powershell only.

X

X

X

X

For more information about the SharePoint 2013 service applications check out the Services in SharePoint Server 2013 Visio diagram on Technical diagrams for SharePoint 2013 (Technet)

Thursday, June 6, 2013

How to use FM Radio API in Windows Phone

In this post I am going to show you how to use FM Radio API in Windows Phone.

The Microsoft.Devices.Radio namespace contains the FMRadio API

Step-1
Add the following name space in your .CS file.
using Microsoft.Devices.Radio;
 
Step-2

  1: // create an instance of the FMRadio class.
  2: FMRadio oRadio = FMRadio.Instance;
  3: // Turn the radio on.
  4: oRadio.PowerMode = RadioPowerMode.On;
  5: // set the region. 
  6: oRadio.CurrentRegion = RadioRegion.UnitedStates;
  7: // set the frequency.
  8: oRadio.Frequency = 94.9;


Download Source code here


 


Happy Coding

Tuesday, May 28, 2013

Resolving XMind can’t open after updating to JRE7

 

I recently noticed that XMind stopped working after updating to Java Runtime Environment (JRE). It gave an error stating

A Java Runtime Environment (JRE) or Java Development Kit (JDK) must be available in order to run XMind. No Java virtual machine was found after searching the following locations: C:\Program Files (x86)\Java\jre6\bin\javaw.exe

I solved it by simply making a copy of the JRE7 folder (default installed underneath C:\Program Files (x86)\Java ) and renaming that copy to JRE6.  Worked like a charm.

 

Technorati Tags: ,,

Thursday, May 23, 2013

Some quotes from actual performance appraisals

"Since my last report, this employee has reached rock bottom and has started to dig."
"His men would follow him anywhere, but only out of morbid curiosity"
"I would not allow this employee to breed"
"This employee is really not so much of a has-been, but more of a definite won't be"
"Works well when under constant supervision and cornered like a rat in a trap"
"When she opens her mouth, it seems that it is only to change feet"
"He would be out of his depth in a parking lot puddle"
"This employee is depriving a village somewhere of an idiot"
"This employee should go far, and the sooner the better"
"Got a full 6-pack, but lacks the plastic thing to hold it all together"
"A gross ignoramus - 144 times worse than an ordinary ignoramus"
"He certainly takes a long time to make his pointless"
"He doesn't have ulcers, but he's a carrier"
"I would like to go hunting with him sometime"
"He's been working with glue too much"
"He would argue with a signpost"
"He has a knack for making strangers immediately"
"He brings a lot of joy whenever he leaves the room"
"When his IQ reaches 50, he should sell"
"If you see 2 people talking and one looks bored, he's the other one"
"A photographic memory but with the lens over the cap"
"A prime candidate for natural deselection"
"Donated his brain to science before he was done using it"
"Gates are down, the lights are flashing, but the train isn't coming"
"Has 2 brains, one is lost, the other is out looking for it"
"If he were any more stupid, he'd have to be watered twice a week"
"If you give him a penny for his thoughts, you'd get change"
"If you stand close enough to him, you can hear the ocean"
"It's hard to believe that he beat out 1,000 other sperm"
"One neuron short of a synapse"
"Some drink from the fountain of knowledge, he only gargled"
"Takes him 1 1/2 hours to watch 60 Minutes"
"The wheel is turning, but the hamster is dead"

Technorati Tags: ,,

Monday, May 20, 2013

Belgian Windows 8 contest : App race

 
Only 31 days left for the Belgian Windows 8 contest: App race. For more info check out

 

Mental note: Windows Phone 7 backup location

By default, Zune makes a backup of your Windows Phone 7, prior to the update procedure. This is so that, in case of failures, it can revert back the phone to its previous state. The backups are automatically stored on the rive where Windows is installed, in the folder Users\Your User Name\AppData\Local\Microsoft\Windows Phone Update.

Technorati Tags: ,,

Saturday, May 18, 2013

Functional stupidity and the corporate rebel

The prestigious Journal of Management published an article in November 2012 called “A stupidity-based theory of organizations” which defined a new interesting term: functional stupidity. Functional stupidity can be defined as follows:

Functional stupidity is organizationally-supported lack of reflexivity, substantive reasoning and justification by hierarchically structured organizations to avoid disintegration (or at least avoid internal friction) and it refers to an absence of reflection and refusal to justify certain decisions, forms of stupidity management repress or marginalize doubt and block communicative action. Members of these organizations are only allowed to work within well defined boundaries and are encouraged only to focus on specific tasks without questioning why.

This seems to be quite contradictory with the contemporary view upon organizations which claims that modern organizations are knowledge intensive and that organizations can only survive when they get the best out of their key asset, their employees.

Short-term use of intellectual resources, consensus and an absence of disquieting questions about decisions and structures may oil the organizational machinery and contribute to harmony and increased productivity in a company,” Mats Alvesson, professor of organization studies, and one of the co-authors, writes. “However, it may also be its downfall.” One of the consequences of functional stupidity is killing innovation and evolution through learning.

The articles also outlines a number of behaviors which are typical of functional stupidity. It also seems that larger organizations are more prone to it. I think this has to do with the fact that they typically boil down their objectives into specific targets which should be attained without question. These objectives and they way of working is often backed by hierarchies, bureaucratic rules and a extremely well documented processes.

I think that at times it is a good thing to question the obvious, be a corporate rebel (Check out www.rebelsatwork.com for some interesting insights and thoughts or read the Rebels at work: motivated to make a difference e-book) and stir up new ideas that often are uncomfortable for the powers that be. Rebel for the ideas that you believe will make a difference because it is all to easy to find a reason not to change.

To finish of, a quote from Marc Buelens, professor at Vlerick Business School, which he added to his article in Trends magazine (Functioneel onwetend, de aantrekkingskracht van veilige paden, 21 maart 2013):

Functional stupidity provides a lot of comfort to management, but together these useful idiots can do quite a lot of stupid things.

Wednesday, May 15, 2013

Why setting a control Height and Width to 0 is not the brightest idea inside a Windows Phone project

I am doing this small post because I have battled the whole morning with this bug and finally got it and it might save you some time if you read it and have the same problem. 

Scenario: Pivot with two items and at some point the swipe on one of the items doesn't work anymore. Putting a button on the PivotItem that doesn't swipe I can still change the selected item and the second item still swipes correctly.

Cause: I was setting the Height=0 and Width=0 on a control inside the PivotItem (in my project I don't want my control to be collapsed). The problem presents itself if you set any of the controls inside a PivotItem to Height and Width = 0 when the PivotItem is selected. If on the other hand you set the Height and the Width to anything >1 the PivotItem continues to swipe correctly. Even more strange: if the PivotItem is not selected when  you set the Width and Height to 0 and swipe to the control's PivotItem everything will still work correctly. So pay attention better not use set Width and Height =0 on UI controls. 

If you want to test it yourself and maybe tell me what really happens I am attaching a small project created from a Windows Phone Pivot application where I've added a menu that will set the Height and Width of the list inside the first PivotItem to 0. I also set the background of the first PivotItem to green so you will see that it is still expanded. 



How to reproduce the problem: If you execute the menu command with the first PivotItem selected you will see that the pivot doesn't swipe anymore. If you change the values to 1, run the app again and execute the menu with the first PivotItem selected you will see that the pivot still swipes correctly. If, on the other hand, you let the values set to 0 but when executing the menu you have the second PivotItem selected you will see that the first item stil swipes correctly. Bug? Feature? Just pay attention to setting controls to Width and Height 0 because you might have problems with the UI and you won't know what is causing it.


NAMASTE









How to launch the Marketplace in the Windows Phone 7 application

 

In this post I am going to show you How to launch the Marketplace programmatically.

follow the below mentioned steps:

Step-1 Create a new Silverlight Windows Phone Application
Step-2 In your MainPage.cs and add a using directive to the Microsoft.Phone.Tasks namespace.
Step-3 Add the following in the constructor of MainPage.cs after calling the InitializeComponent() method:

  1: var task = new MarketplaceHubTask();
  2: task.ContentType = MarketplaceContentType.Applications;
  3: task.Show();


Step-4 Run the application by pressing F5 Key.


 


Happy Codeing

Monday, May 13, 2013

Fix Panorama layout when upgrading your project to OS 8.0 SDK

  This will be a really short blog post but might save you some time if you have an OS 7.1 Panorama project and decide to upgrade the project to 8.0 SDK. After the upgrade you might see that the layout of your old page changed and you have less content available for the items and also the header looks different. Don't try to fix the problem by changing the margin of the control on the OS 8.0 SDK. The reason why this happens is because the Windows Phone SDK team decided to "tweak" a little bit the default style for the Panorama control, to be more precise the TitleLayer part of the style.
  On Windows Phone OS 7.1 projects the TitleLayer looks like this:

 <controlsPrimitives:PanningTitleLayer x:Name="TitleLayer" CacheMode="BitmapCache" ContentTemplate="{TemplateBinding TitleTemplate}" Content="{TemplateBinding Title}" FontSize="187" FontFamily="{StaticResource PhoneFontFamilyLight}" HorizontalAlignment="Left" Margin="10,-76,0,9" Grid.Row="0"/>  

while on OS 8.0 we have:

 <Primitives:PanningTitleLayer x:Name="TitleLayer" CharacterSpacing="-35" ContentTemplate="{TemplateBinding TitleTemplate}" Content="{TemplateBinding Title}" FontSize="170" FontFamily="{StaticResource PhoneFontFamilyLight}" HorizontalAlignment="Left" Margin="10,-34,0,0" Grid.Row="0"/>  


You can see that not only the margin have changed (the reason why on OS 8.0 version we have less space in the content -44px ), but also the font size changed from 187 to 170 producing these visual differences:


The solution to this problem is pretty simple: extract the old style of the Panorama control (the easiest way is using Blend) and apply to both WP7.1 and OS 8.0 versions of your project. This way the UI will be consistent between the two versions of the app. If you don't want to use Blend I am attaching the default OS 7.1 style so you can directly copy/paste it in your project and apply it to your Panorama control.

 <Style x:Key="PanoramaStyleWP71" TargetType="controls:Panorama">  
<Setter Property="ItemsPanel">
<Setter.Value>
<ItemsPanelTemplate>
<controlsPrimitives:PanoramaPanel x:Name="panel"/>
</ItemsPanelTemplate>
</Setter.Value>
</Setter>
<Setter Property="Foreground" Value="{StaticResource PhoneForegroundBrush}"/>
<Setter Property="Background" Value="Transparent"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="controls:Panorama">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<controlsPrimitives:PanningBackgroundLayer x:Name="BackgroundLayer" HorizontalAlignment="Left" Grid.RowSpan="2">
<Border x:Name="background" Background="{TemplateBinding Background}" CacheMode="BitmapCache"/>
</controlsPrimitives:PanningBackgroundLayer>
<controlsPrimitives:PanningTitleLayer x:Name="TitleLayer" CacheMode="BitmapCache" ContentTemplate="{TemplateBinding TitleTemplate}" Content="{TemplateBinding Title}" FontSize="187" FontFamily="{StaticResource PhoneFontFamilyLight}" HorizontalAlignment="Left" Margin="10,-76,0,9" Grid.Row="0"/>
<controlsPrimitives:PanningLayer x:Name="ItemsLayer" HorizontalAlignment="Left" Grid.Row="1">
<ItemsPresenter x:Name="items"/>
</controlsPrimitives:PanningLayer>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>


NAMASTE

Thursday, May 9, 2013

Type forwarding and XAML sharing between WP OS 7.1 and 8.0 projects

    This post is about a new feature available in Windows Phone OS 8.0 SDK called Type Forwarding.

    Have you ever wondered how does the Windows Phone 8.0 SDK handles the fact that the Panorama, Pivot controls changed the namespace and the assembly from OS 7.1 SDK to OS 8.0 SDK? (80% that you haven't :) ). I recently had to migrate an OS 7.1 project to OS 8.0, but also keep the old one (duplicated the old project and upgrade the duplicated one).

    Here is the story of what happens when you upgrade an OS 7.1 project that uses Panaroma or Pivot to OS 8.0:
    If you start a new Windows Phone Pivot App with the target OS 8.0 inside MainPage.xaml the prefix "phone" is used for the Pivot control where "phone" is:

 xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"  

    If, on the other hand, you create a new Windows Phone Pivot App with the target OS 7.1 inside MainPage.xaml the prefix "controls" is used for the Pivot/Panorama control where "controls" is:

 xmlns:controls="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls"  

    The real "magic" happens when you upgrade the Windows Phone 7.1 project to OS 8.0. The MainPage.xaml page doesn't change (you will still see the "controls" tag is kept in order to be able to better share the code between the versions), but instead a reference to Microsoft.Phone.Controls.dll is added to the OS 8.0 reference that is not used if you create a new project with target OS 8.0. If you wonder if by adding this reference you use the old version of the controls the answer is NO. What this assembly does is that is uses a really neat and new  feature of the .Net compiler called Type Forwarding. This feature can be used when you move a class from one namespace/dll (assembly) to another and you don't want to recompile the application to reference the new dll but you will only deploy the two dlls where the first one (the one that the application already knew uses the Type Forwarding to tell the application that a certain class/es moved to another assembly). In the case of Windows Phone OS 8.0 SDK the usage is even "cooler" as it enables you to use the same XAML for both OS 7.1 projects and OS 8.0 ones. Inside AssemblyInfo.cs of Microsoft.Phone.Controls.dll OS 8.0 version we have all the declarations needed to forward the types to their new locations:

 [assembly: TypeForwardedTo(typeof(Panorama))]  
[assembly: TypeForwardedTo(typeof(PanoramaItem))]
[assembly: TypeForwardedTo(typeof(Pivot))]
[assembly: TypeForwardedTo(typeof(PivotItem))]
[assembly: TypeForwardedTo(typeof(PivotItemEventArgs))]
[assembly: TypeForwardedTo(typeof(AnimationDirection))]
[assembly: TypeForwardedTo(typeof(PanningBackgroundLayer))]
[assembly: TypeForwardedTo(typeof(PanningLayer))]
[assembly: TypeForwardedTo(typeof(PanningTitleLayer))]
[assembly: TypeForwardedTo(typeof(PanoramaPanel))]
[assembly: TypeForwardedTo(typeof(PivotHeaderItem))]
[assembly: TypeForwardedTo(typeof(PivotHeadersControl))]

I am attaching a small project called TypeForwarding that implements the same functionality as Microsoft.Phone.Controls.dll OS 8.0 version.

Other usages that I can thing of:

  • Flurry SDK changes the name of the namespace for the Api class for WP7SDK to WP8SDK (bad choice when you need code sharing). If you want to keep the same code for the OS 7.1 and the OS 8.0 version of the app you will have to use conditional compiling for every file where you use the Api class. Much easier would be to create an OS 8.0 library project with the default namespace WP7SDK and forward the Api class to the WP8SDK added as a reference to the library project. This way the old WP7SDK will continue to work as it was on the OS 8.0 using the OS 8.0 version of the Flurry SDK.
  • MVVM Light. If you use inside your XAML the EventToCommand this is not xaml shareable between OS 7.1 and OS 8.0 because the assemblies changes from GalaSoft.MvvmLight.Extras.WP71.dll to GalaSoft.MvvmLight.Extras.WP8.dll. The easiest approach in this case (an open source) would be to recompile the dll and use the same name for both versions of the dll. But if you don't have access to the source code of the dll you could use type forwarding.  Also a third approach would be to derive your on class like MyEventToCommand and use this inside the xaml.
Keep in mind this neat feature because you might need it. I would also love to see, in the next version of the SDK, the possibility to use MarkupExtension this way we could conditionally compile parts of the XAML depending on the version of the SDK the app is running on. Have a look at this blog post that explains how it works on WPF projects.



Till next post NAMASTE and have fun coding for Windows Phone!

Wednesday, May 8, 2013

Community Day 2013 – Building search driven Windows 8 and Windows Phone 8 apps with SharePoint Server 2013

I will be delivering a session at Community Day Belgium – registrations will open up next week – there is a great lineup of sessions – so don’t hesitate.

Session abstract: Combine the power of Windows 8 with the flexibility and interoperability of SharePoint 2013 search. This session will walk through building Windows 8 applications using SharePoint 2013's REST-based search API to build rich, compelling user experiences. We will leverage the new people and social search capabilities in SharePoint 2013 to build both a Windows 8 client and Windows Phone 8 client.

If you have a specific scenario that you want to see in this session, don’t hesitate to leave a comment.

Wednesday, May 1, 2013

Enable Azure Mobile Services for "pure" Windows Phone 7.1 Xna Games

     Recently somebody asked me for an advice on what library should he use to communicate with an Azure Mobile Service for an Windows Phone OS 7.1 and Windows 8 Xna game. My answer was, of course, the Windows Azure Mobile Services client library available on NuGet as I remembered that the prerelease version works also for Windows Phone OS 7.x applications.

The "problem" is that the library will not install if the game is a pure Xna Windows Phone project.

There are 2 (maybe 3 :) ) solutions to this problem:
1. Migrate your XNA project to an "Windows Phone XAML and XNA App" and on this type of project the client library will install correctly.
2. You could use a small hack in order to force NuGet to install the Azure Mobile Services client library on your XNA project. The hack is pretty simple:
  • open the YourProject.csproj file with an text editor (like Notepad) and add these 3 line (not sure if all 3 of them are needed but doesn't matter as it is only done to force the library to install):
  •  <SilverlightVersion>$(TargetFrameworkVersion)</SilverlightVersion>  
    <TargetFrameworkProfile>WindowsPhone71</TargetFrameworkProfile>
    <TargetFrameworkIdentifier>Silverlight</TargetFrameworkIdentifier>
  •  Visual Studio will see that the project has been modified so it will ask to Reload the project. Reload it (don't try to build the project as it won't), open the Package Manager Console and write:
     Install-Package WindowsAzure.MobileServices -Pre   
    the package should now install.
  • Reopen the .csproj file in Notepad and remove the 3 lines we've previously added, save and reload the project in Visual Studio. The project should compile correctly and you should be able to use the Azure Mobile Services client library.

The only thing that doesn't seem to work is make Visual Studio recognize the await keyword for the XNA project. You will have to use the ContinueWith syntax:

 void TestAzureMobile()  
{
todoitem item = new todoitem { Text = "Awesome item XNA" };
ms.GetTable<todoitem>().InsertAsync(item).ContinueWith((task)
=>
{
//do what you need here
});
}

3. Came to me while writing the post. Guess the most "elegant" way is to add an Windows Phone Class library to your project, add and use the Azure Mobile Service client library from the class library, reference the class library from your XNA project. Tried this one but the MobileServiceClient seems to fail initialization with 'System.TypeInitializationException'.

Take in consideration that the Azure Mobile Services client library is still a pre-release version in this moment so for the release they might fix/enhance it and you could install it on XNA projects without any hack needed (it is a PCL library).

Wednesday, April 24, 2013

Detect the screen resolution for Windows Phone OS 7.1 applications

    As you probably know Windows Phone 7.1 applications run perfectly on Windows Phone 8 devices. This means that your application/s could run on multiple display resolutions (which are the resolutions supported by Windows Phone 8 devices). If you want to take advantage of the new resolutions (for example downloading higher quality images for higher resolutions devices, fix some minor UI anomalies on higher resolutions) you will need to know the ScaleFactor of the device. The property is only available in the Windows Phone 8.0 SDK, but the good news is that you can access it using reflection.

Solution:
We retrieve the Get method of the ScaleFactor property and invoke it only if the application is running on an Windows Phone 8 device.

Here is the source code:
  public static Size DisplayResolution  
{
get
{
if (Environment.OSVersion.Version.Major<8)
return new Size(480,800);
int scaleFactor=(int) GetProperty(Application.Current.Host.Content, "ScaleFactor");
switch (scaleFactor)
{
case 100:
return new Size(480, 800);
case 150:
return new Size(720, 1280);
case 160:
return new Size(768, 1280);
}
return new Size(480, 800);
}
}
private static object GetProperty(object instance, string name)
{
var getMethod= instance.GetType().GetProperty(name).GetGetMethod();
return getMethod.Invoke(instance, null);
}

I am also attaching a small sample Windows Phone OS 7.1 test project.


SOURCE CODE

P.S. I think Telerik could use this method to fix this RadToolTip visual anomaly (the 1 pixel width lines that I have filled with blue for contrast) :


NAMASTE

Tuesday, April 16, 2013

3 ways to force the WebBrowser control to logout from Facebook

     Decided to write this post because it took me some time to find the answer. Maybe you already know that if you use OAuth Facebook connect inside your Windows Phone application there is one step where you use the WebBrowser control to let the user authenticate on the Facebook server and authorize your app. The "problem" presents itself when you want to link another user because the WebBrowser control has already memorized the old credentials and will automatically use them. What needs to be done is to logout the old user from the WebBrowser without actually telling the user to go on the web page and click logout. I have found 3 easy ways to do that: the first two will work on both Windows Phone 7.x and Windows Phone 8 and are Facebook specific and the third one will only work on Windows Phone 8 (generic method for OAuth providers). The 3 methods can use the WebBrowser control headless (you don't actually have to show the WebBrowser control to the user and don't even have to have the webbrowser attached to a Page):  

Method 1: described by Rene Schulte in this blog post  
The method constructs the logout Uri using your AppId and a SessionKey that is obtained from the AccessToken you got when the user authenticated.

Get the SessionKey:
  private static string ExtractSessionKeyFromAccessToken(string accessToken)  
{
if (!String.IsNullOrEmpty(accessToken))
{
var parts = accessToken.Split('|');
if (parts.Length > 2)
{
return parts[1];
}
}
return String.Empty;
}

Obtain the logout Uri:
  public Uri GetLogoutUri(FacebookCredentials credentials)  
{
var sessionkey = ExtractSessionKeyFromAccessToken(credentials.AccessToken);
var url = String.Format("http://facebook.com/logout.php?app_key={0}&session_key={1}&next={2}", EndpointData.FacebookAppId, sessionkey, EndpointData.FacebookLogoutCallbackUrl);
return new Uri(url);
}

Make the WebBrowser navigate to the logout Uri:
 Browser.Navigate(FacebookService.GetLogoutUri(EndpointData.Settings.Facebook));  

Method 2:
If for some reason you don't have the Facebook AppId available (my case) you can use the WebBrowser to navigate to the Logout page https://www.facebook.com/logout.php and after the page gets loaded you just execute the script document.forms['logout_form']:
 wb.LoadCompleted += wb_LoadCompleted;  
wb.Navigate(new Uri("https://www.facebook.com/logout.php"));
Once the page gets loaded:
 void wb_LoadCompleted(object sender, System.Windows.Navigation.NavigationEventArgs e)  
{
wb.LoadCompleted -= wb_LoadCompleted;
if (wb.SaveToString().Contains("logout_form"))
wb.InvokeScript("eval", "document.forms['logout_form'].submit();");
}

Method 3:
This is the easiest one, but will only work on Windows Phone 8: call the new WebBrowser async method ClearCookiesAsync(). This method works for every OAuth provider (Dropbox, Box, Skydrive, Picasa, Flickr, Google Drive... infinite list).

NAMASTE

Thursday, April 11, 2013

SharePoint 2013 : the Big Five

Trends impacting collaborative tools and platforms

I have been working for quite some years now consulting companies mostly on the technical side of building and designing collaborative environments but when preparing for a presentation about why people should upgrade their current environment to the latest (and off course greatest) version I tried to summarize some trends which significantly impact the way that we should think about these environments.
  • It’s a multi-device & mobile world.  90% of people use multiple screens sequentially to accomplish their goals with search being the most common ways consumers continue from one device to another (Source Google: The New multi-screen world study )
  • Social collaboration is the new norm. 82% of the world’s online population engages in social networks. The usage of social tools has changed the mindset of people and is blurring the division between private and work life. People are expecting to same ease of connecting with co-workers and keeping up to date  within the enterprise as they are used to connect and follow their social network outside  outside of it. The fact that a new digital generation ( a.k.a Generation Y) is entering the workforce will put even more pressure on companies to embrace social tools.
  • Businesses are faced with an increased pace of change. Most people seem to think that the accelerating change is typical for technology but this accelerated pace of change also applies to business in general. According to research the average lifespan of a S&P 500 company is 18 years today (compared with 68 years in 1950). At this rate 75% of the S&P 500 will be replaced by 2027 (Source Innosight.com, 2012: Creative destruction whips through corporate America). Extrapolating from past patterns by the end of the year 2020, the average lifespan will have been shortened to about 10 years (See Survival and performance in the era of discontinuity). The only corporate survivors will be those that can increase the rate of creative destruction without losing control of present operations.
  • No man is an island – collaboration is required for value creation. 66% of CIOs from top-performing organizations see collaboration as key to innovation. (Source: IBM CIO study, 2001). Most tasks performed by knowledge workers have become so complex that they require people with diverse skill sets and from multiple disciplines to collaborate. Unfortunately organization are still quite hierarchical organized which impedes efficient collaboration. Definitely read – Enterprise Social Networks what has changed and the changing role of middle management
  • Renewed focus on people as the core asset in the battle for companies survival.  Although the next quote was made by Andrew Carnegie at the end of the 19th century it holds more true then ever.
  • The only irreplaceable capital an organization possesses is the knowledge and ability of its people. The productivity of that capital depends on how effectively people share their competence with those who can use it.
    If you look at information workers (the typically users of your platform) you will notice a shift in structure based work (Processes, routines,controls,…) to more knowledge based work (research, problem-solving, relationship driven,…) But knowledge workers are more likely to excel when they are engaged. Gallup estimates that engaged employees are 18% more productive and that attrition decreases with 51%. At the same time employees are expecting more from their employers. They don’t just go to work to get paid, they want to be motivated, challenged and have a clear purpose( definitely check out the video What motivates us?)
    Related posts:
  • Enterprise 2.0 and organizational culture
  • Knowledge and talent in a people ready business
  • Knowledge is power! So why share your knowledge?
  • The value in social networks
  • Colleagues, Social Distance & Relevance in People Search, and other Social Networking tools in SharePoint
  •  

Thursday, April 4, 2013

Value cannot be null.Parameter name: parentContext in Windows Phone 7


Today morning I am just open Visual Studio 2010 and create a new Windows phone project and came across an issue with windows phone xaml page with the following error in design view.

Value cannot be null.Parameter
name: parentContext in Windows Phone 7

To rectify this issue I did two worked around and both are worked.
1) Build your project and close the page windows and then open.
2) Close the Visual Studio IDE and re-launch it.

Hope it helps.

SharePoint Saturday Belgium 2013 – Building the “Hot or Not” app on SharePoint 2013 … or how not to sell social to your client or boss

I’m presenting a SharePoint development session on social at SharePoint Saturday Belgium 2013  end of April. I’m still in the brainstorming phase but below is the abstract – so if you have something specific you want to see in the session – leave a comment;

Session abstract: ​Enterprise social networks allow you share best practices within organizations, identify co-workers with particular expertise, exchange knowledge and work more efficiently together on projects , but they can also be a lot of fun. Microsoft has made some significant investments in social capabilities with SharePoint Server 2013. In this session we will explore the different social capabilities in SharePoint 2013 and show how to build a SharePoint app which leverages social and search features to build your own "Hot or Not" app. Technologies covered in this session include the new Social and Search REST APIs in SharePoint 2013, the SharePoint app framework, Azure , Windows 8 and Windows Phone 8 ... but it is mostly about having some fun to build a social app. Warning: session is heavy on code ... and pretty girls.

Wednesday, April 3, 2013

Presenting at Be the Change Hero for better information collaboration in your organization

 

I’m presenting the keynote next week at “Be the Change Hero for better information collaboration in your organisation” in Brussels – if you are interested check out Be the Change Hero roadshow event site.  Focus of the sessions is on getting more value out of yor SharePoint investement. For those of you who can not attend – I will share the slidedeck afterwards.

Technorati Tags: ,

Tuesday, April 2, 2013

Smooth scrolling content on Windows Phone

     Gotta say that I am not 100% satisfied about the title of this blog post, but since I haven't found a better one I will use this one (don't get it wrong windows phone has smooth scrolling implemented). This post is focusing on how to smooth scroll the content of a ScrollViewer. If you are using the ScrollViewer you know that it already has the method ScrollToVerticalOffset that can be used to manually scroll the content but this method doesn't have any animation implemented so you will see only a fast redraw of the new content without getting the "feeling" that the content scrolled to the new position. The easiest way to achieve this task would be using a StoryBoard with an Animation on the property VerticalOffset of the ScrollViewer, but VerticalOffset is a read-only property so it cannot be set and therefore cannot be used for animation.
     The solution I found was to build a custom control and add a custom property that can be used as a target for a DoubleAnimation. The attached sample (see the link at the end of the post) is using a ListBox as the content of my Custom Control but you can use anything else inside the control (a better approach for the ListBox would be to create a custom control derived directly from ListBox and use the built-in ScrollViewer). 
      Let's start from the XAML part of the User Control:

  <ScrollViewer x:Name="scroller">  
<ContentPresenter Content="{Binding ContentArea, ElementName=userControl}"/>
</ScrollViewer>

    So we have a ScrollViewer which inside has a ContentPreseter that has its content binded to the control's property ContentArea. Now let us have a look at the .cs code.

 public static readonly DependencyProperty VerticalOffsetProperty = DependencyProperty.Register("VerticalOffset",  
typeof(double), typeof(SmoothScroller), new PropertyMetadata(VerticalOffsetPropertyChanged));
public double VerticalOffset
{
get { return (double)this.GetValue(VerticalOffsetProperty); }
set { this.SetValue(VerticalOffsetProperty, value); }
}
private static void VerticalOffsetPropertyChanged(object sender, DependencyPropertyChangedEventArgs args)
{
SmoothScroller cThis = sender as SmoothScroller;
cThis.scroller.ScrollToVerticalOffset((double)args.NewValue);
}
public static readonly DependencyProperty ContentAreaProperty = DependencyProperty.Register("ContentArea", typeof(object), typeof(SmoothScroller), null);
public object ContentArea
{
get { return (object)GetValue(ContentAreaProperty); }
set { SetValue(ContentAreaProperty, value); }
}

     The property that we will use for animation is the VerticalOffset that uses the method VerticalOffsetPropertyChanged to scroll to a vertical offset inside the control's scroller. The property VerticalOffset can be animated and we will use it to smooth scroll the ListBox content.
     Here is the content of the MainPage.xaml

  <uc:SmoothScroller x:Name="smoothScroller">  
<uc:SmoothScroller.ContentArea>
<ListBox x:Name="lstItems" ItemsSource="{Binding Items}" ScrollViewer.VerticalScrollBarVisibility="Disabled" ScrollViewer.HorizontalScrollBarVisibility="Disabled" ItemTemplate="{StaticResource DataTemplate}" >
<ListBox.ItemContainerStyle>
<Style TargetType="ListBoxItem">
<Setter Property="HorizontalContentAlignment" Value="Stretch"></Setter>
</Style>
</ListBox.ItemContainerStyle>
</ListBox>
</uc:SmoothScroller.ContentArea>
</uc:SmoothScroller>

     So we have the SmoothScroller control which inside its ContentArea has a ListBox (the ListBox has it's scrollviewer disabled). What the sample does is it is changing the selected item every second (incrementing the selectedindex) and scrolls the content so that the newly SelectedItem is centered in the ScrollViewer. Here is the code used for scrolling:

  void dt_Tick(object sender, EventArgs e)  
{
((ListBox)smoothScroller.ContentArea).SelectedIndex = idx;
var container = ((ListBox)smoothScroller.ContentArea).ItemContainerGenerator.ContainerFromIndex(idx) as FrameworkElement;
var transform = container.TransformToVisual(smoothScroller.scroller);
var elementLocation = transform.Transform(new Point(0, 0));
double newVerticalOffset = elementLocation.Y + smoothScroller.scroller.VerticalOffset - smoothScroller.scroller.ActualHeight / 2 ;
//Animate transition
DoubleAnimation verticalAnimation = new DoubleAnimation();
verticalAnimation.From = smoothScroller.scroller.VerticalOffset;
verticalAnimation.To = newVerticalOffset;
verticalAnimation.Duration = new Duration(TimeSpan.FromMilliseconds(500));
var sb = new Storyboard();
sb.Children.Add(verticalAnimation);
Storyboard.SetTarget(verticalAnimation, smoothScroller);
Storyboard.SetTargetProperty(verticalAnimation, new PropertyPath(SmoothScroller.VerticalOffsetProperty));
sb.Begin();
idx++;
if (idx >= 56)
dt.Stop();
}

     Pretty basic: select the new index in the ListBox, calculate the new VerticalOffset so that the newly selected item is centered in our scrollviewer and create and start a 500ms animation for the SmoothScroller.VerticalOffsetProperty. Anyway I am sure that you will better understand how it works when you will try the sample code.
     The sample is far from perfect (before starting a new animation I should check if the old one finished, should not automatically scroll when the user is manipulating the list,...).
     Here is a screenshot from the sample:

As usual let me know if you need help. The code works on both Windows Phone 7.1 and Windows Phone 8 SDK.

SOURCE CODE


Monday, April 1, 2013

Building a Windows 8 app for SharePoint 2013 Part 1: using Javascript and CSOM

I followed two sessions about building a Windows 8 app for SharePoint 2013 during the SharePoint conference in Vegas. The two sessions used a different approach for building such an app. In the next couple of blog posts I will outline the different approaches and provide some feedback around it. Let’s start with the CSOM approach.

The SharePoint CSOM and Javascript approach to build Windows 8 apps
During the session Fun with SharePoint Social, CSOM and Windows 8 delivered by Mark Rackley and Eric Harlan (Slideshare for a local BIWUG redelivery available here) at SharePoint Conference Las Vegas a solution depicted by the image below was built. For a complete walkthrough check out Creating your First Windows 8 Application using the Client Object Model (CSOM) and JavaScript
from Mark.

For those of you unfamiliar with CSOM – this is an abbreviation of the  SharePoint Client Side Object Model. So the basic setup was actually a Visual Studio solution which combines a JavaScript WinRT project and a Windows Runtime compontent.  Listed below is  a download link with a  very simple example to get you started.  This is how the code of the Windows Runtime Component looks like – it is basic CSOM code.  Some things you should think about:
  • Add a reference to the required Microsoft SharePoint Client Runtime components
  • Make sure that you pass in the required credentials – the code below assumes that the Windows 8 machine is in the same domain as your SharePoint Server and that you can log in with integrated security
  • The SocialFollowingManager is the most important class – for background info on follows in SharePoint 2013 – check out Common programming tasks for following content in SharePoint 2013
  • You will need to use a separate object to pass the information from the SocialFollowingManager back to the Javascript Windows Store App. By default the SocialFollowingManager returns a ClientResult of type SocialActor which is not a valid Windows Runtime Parameter type and which can’t be returned in a public method
  • You can’t use nested classes – that’s whyFollowedContent is a separate class.
  • If you receive “Unable to connect to the remote server” when connecting to SharePoint you probably still need to make sure that your application has the correct capabilities enabled.  Open up your Application Manifest and make sure that you have “Enterprise Authentication” and  “Private Networks (Client and Server) checked



  1: using System;
  2: using System.Collections.Generic;
  3: using System.Linq;
  4: using System.Text;
  5: using System.Threading.Tasks;
  6: using System.Net;
  7: using Microsoft.SharePoint.Client;
  8: using Microsoft.SharePoint.Client.Social;
  9: 
 10: namespace CSOM
 11: {
 12:     public sealed class FollowedContent
 13:     {
 14:         public string ID { get; set; }
 15:         public string Type { get; set; }
 16:         public string Name { get; set; }
 17:         public string Uri { get; set; }
 18:     }
 19:     
 20:     public sealed class Social
 21:     {
 22: 
 23:         public static FollowedContent[] GetFollowedContent()
 24:         {
 25:             
 26:             ClientContext ctx = new ClientContext("http://sp2013");
 27:             ctx.Credentials = System.Net.CredentialCache.DefaultCredentials;
 28:             
 29:             SocialFollowingManager sfmgr = new SocialFollowingManager(ctx);
 30:             ClientResult<SocialActor[]> actors = sfmgr.GetFollowed(SocialActorTypes.All);
 31: 
 32:             sfmgr.Context.ExecuteQuery();
 33: 
 34:             FollowedContent[] followedContent = new FollowedContent[actors.Value.Length];
 35: 
 36:             int index = 0;
 37: 
 38:             foreach (SocialActor actor in actors.Value)
 39:             {
 40:                 FollowedContent content = new FollowedContent();
 41:                 content.ID = actor.Id;
 42:                 content.Type = actor.ActorType.ToString();
 43:                 content.Name = actor.Name;
 44:                 content.Uri = actor.Uri;
 45:                 followedContent[index++] = content;
 46: 
 47:             }
 48: 
 49:             return followedContent;
 50:         }
 51:     }
 52: }
 53: 


I like this approach of building Windows 8 apps since it allows for a clean separation of the SharePoint codebase from the UI part. At the same time SharePoint developers can leverage the SharePoint object model using CSOM.  It is possible to leverage numerous Javascript libraries (such as JQuery UI) to build a compelling user experience.


Code samples – download BIWUGApp1.rar