SharePoint 2013 installation – unsupported 16-bit application


Hello everyone,

Today I’ll talk about installing the preview version of SharePoint 2013. In particular the prerequisites installation.

In fact, when I wanted to do this installation, for both version, I found myself face to this error message. « unsupported 16-bit application.. »

First I tried to copy the source directly on the server and restart the installation, without success.

Finding no real solution to the problem, I decided to find another way to do, namely get myself to install the sources.

While searching, I came across this article: http://www.dontpapanic.com/blog/?p=241

Exactly what I wanted! (thank you Paul!)

Here are the links to the prerequisites of SharePoint 2013.

Having copied the contents of the iso in a folder “SP” on the desktop, simply put. Bat file in the root folder of our iso (where the PrerequisiteInstaller.exe is)


set PreReqPath=C:\Users\Administrator\Desktop\SP\prerequisiteinstallerfiles

PrerequisiteInstaller.exe /SQLNCli:%PreReqPath%\sqlncli.msi  ^

/PowerShell:%PreReqPath%\Windows6.1-KB2506143-x64.msu  ^

/NETFX:%PreReqPath%\dotNetFx45_Full_x86_x64.exe  ^

/IDFX:%PreReqPath%\Windows6.1-KB974405-x64.msu  ^

/Sync:%PreReqPath%\Synchronization.msi  ^

/AppFabric:%PreReqPath%\WindowsServerAppFabricSetup_x64.exe  ^

/IDFX11:%PreReqPath%\MicrosoftIdentityExtensions-64.msi  ^

/MSIPCClient:%PreReqPath%\setup_msipc_x64.msi  ^

/WCFDataServices:%PreReqPath%\WcfDataServices.exe  ^

/KB2671763:%PreReqPath%\AppFabric1.1-RTM-KB2671763-x64-ENU.exe

Hope this helps you as much as it helped me!

Christopher.

Advertisements

Create custom field type with user control

Hello everybody,

Today I will talk about a problem I had with Custom Field Type.

The goal was to create a custom field type and have a user control for display. Control was necessary because I had to apply a regular expression that conditioned the formatting.

There are many tutorials explaining step by step how to do this operation but for the sake of cohesion I will remember those steps.

1) Add a class field definition

For this example we are going from the standard type of field, type “text”. We will therefore inherit “SPFieldText.” In this class we will define the two constructors of our standard custom field.


2) Mapping xml folder:

To do this, right click on the project, add a folder mapped SharePoint

The xml folder is located in the folder “SharePointRoot\template”

3) Add an xml file in the folder mapped xml

Very important! : The file name must begin with fldtypes_

For this example I called it: fldtypes_TutoCustomField.xml

In this xml file we will describe the properties of our field.

Once these two files are created, we can already see the field in action if we deploy the solution.

Very important! : For the new file type being visible when we create a new field, we must perform a iisreset, recycle the application is not enough.

Create a new list and add our new column.

Until here no problem, we will now add a control to our field.

4) Add the User control.

Very very very very important ! : Here we touch upon the main reason for this tutorial. Namely, avoid you to pull your hair out and send the pc through the window being frustrated (yes I admit it smells lived).

When we add a user control with Visual Studio 2010, this is what it does.

A) If absent, it adds a mapped folder on the file “ControlTemplates”

B) If absent, it adds a folder named by our project

C) it adds the control.

Handy you might say, except that by default, SharePoint does not search the subfolders of the folder ControlTemplates for customs field type, it looks only for components in folder ControlTemplates.

Let’s put our control in the correct folder. Also delete files “. Cs” control, the only thing we need is the “ascx”.

In our ascx file, delete the links to the code behind class of the line “Control”

Became

Now add “RenderingTemplate” that will be used to display our control in the page “edit item” and “view item”.

In the first, “TutoCustomFieldControl” we will have a textbox to retrieve the data. In the second, “TutoCustomFieldControlForDisplay” we will have a label to display the field value.

5) Add the class definition of control.

In this class we will define the behavior of our control, including the possible treatments for display and perform the save.

So let’s create our class “TutoCustomFieldControl” which inherits from “BaseFieldControl”. In this class we will start by declaring the components of our “RenderingTemplate” label “MyCustomNameLabel” and the textbox “MyCustomNameText”

We also need to override two variables: DefaultTemplateName and DisplayTemplateName as follows.

With this override, we specify the name of our custom “RenderingTemplate.

Now let’s override CreateChildControl function.

In this override, we test the type of view. If this is an edition, we fill the textbox with the contents of the field.

We still need a thing. If we allow this class like this, the field changes will not be saved. We must add a saving event on our field.

After loading control, we add the event which, after validation of the page, performs the update of the item.

6) Override the “FieldRenderingControl” class of our field.

The last step is to modify our “TutoCustomField” class to add a surcharge calling our new class “TutoCustomFieldControl”.

Well, now we can deploy our solution. If you did the test field at the end of section 3 the updated code will not be effective in this field. Remove and re-create it to have a solution that works!

7) Change the display in the list.

We can go one step further by changing the rendering of the field in the list.

For this we must add an xsl file. Begin by mapping the xsl folder, this one is in the folder “SharePointRoot\template\layouts”

Then add an xsl file

Very important ! : We need the xsl file named the same as the xml file of our field. It should be called “fldtypes_TutoCustomField.xsl”

We will change the text color in red, for it just add a “span” around the field

Pay close attention to “FieldType” which must match the type of our field.

Let’s deploy our solution without forgetting to make an iisreset for the new file being used.

And voila!

Happy coding to everyone !

Christopher.

SharePoint 2013


Hello everyone,

Today I’ll talk about something we all expect, the new version of SharePoint!

Here are some links that I found during my research on the subject.

  • SharePoint 2013 for IT pros :

http://technet.microsoft.com/en-us/sharepoint/fp142366

Entry point on technet SharePoint 2013 where you can find a lot of information!

  • SharePoint 2013 training for IT pros :

http://technet.microsoft.com/en-us/sharepoint/fp123606

Accessible via the first link but it seemed important to me, you will find a course on what’s new in SharePoint 2013.

  • SharePoint 2013 training for developers :

http://msdn.microsoft.com/en-US/sharepoint/fp123633

  • SharePoint 2013 Video Tutorials:

http://www.sharepoint-videos.com/sharepoint-2013-video-tutorials/

Downloads:

  • SharePoint Designer 2013:

http://www.microsoft.com/en-us/download/details.aspx?id=30346

  • SharePoint Foundation 2013 Preview :

http://www.microsoft.com/en-us/download/details.aspx?id=30345

  • Microsoft SharePoint Server 2013 Preview:

http://technet.microsoft.com/en-US/evalcenter/hh973397.aspx?wt.mc_id=TEC_121_1_4

Good reading and have fun!

Christopher.

Get a list of all SharePoint group’s users including active directory group

Hello everyone,

Today I’ll talk about a request I had some time ago. The client wanted a list of all members of a SharePoint group.

At first sight no worries, just use a

 
SPGroup group;            
group.Users ;

Except that later in development, the use of active directory groups has been determined to facilitate user management.
And here, it does not interest the customer to see the name of its active directory groups! (Strange isn’t it?)

So now, after some research and several tests I found the SPPrincipalInfo class and the PrincipalType attribute : http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.client.utilities.principaltype.aspx

This class, found via the Microsoft.SharePoint.Utilities assembly, tests whether the user is a security group, in other words, if it is an Active Directory group.

So here I am with the first part of my code


SPSecurity.RunWithElevatedPrivileges(delegate
            {

                using (SPSite adminSite = new SPSite(SPContext.Current.Site.ID))
                {
                    using (SPWeb adminWeb = adminSite.OpenWeb(SPContext.Current.Web.ID))
                    {
                        string myGroup = "GroupName";
                        List listeUsers = new List();
                        bool reachedMax;
                        SPPrincipalInfo[] principals = SPUtility.GetPrincipalsInGroup(adminWeb, myGroup, 500, out reachedMax);
                        foreach (SPPrincipalInfo item in principals)
                        {
                            if (item.PrincipalType == SPPrincipalType.SecurityGroup)
                            {
                                string[] temp = item.DisplayName.Split('\\');
                                listeUsers.AddRange(GetGroupMembers(temp[temp.Length - 1]));
                            }
                            else
                                //listeUsers.Add(item.LoginName.ToLower());//display the login name
                                listeUsers.Add(item.DisplayName.ToLower());//display the display name
                        }
                    }
                }
            });				
		

The distinction between users and SharePoint active directory group is made, it now remains only to query the active directory to retrieve all users in that group.



public List GetGroupMembers(string strGroup)
        {
            List groupMemebers = new List();

            try
            {
                DirectoryEntry ent = new DirectoryEntry("LDAP://DC=Test,DC=COM");// Change by your AD link

                DirectorySearcher srch = new DirectorySearcher("(CN=" + strGroup + ")");

                SearchResultCollection coll = srch.FindAll();

                foreach (SearchResult rs in coll)
                {
                    ResultPropertyCollection resultPropColl = rs.Properties;

                    foreach (Object memberColl in resultPropColl["member"])
                    {
                        DirectoryEntry gpMemberEntry = new DirectoryEntry("LDAP://" + memberColl);

                        System.DirectoryServices.PropertyCollection userProps = gpMemberEntry.Properties;

                       
                        //getting user properties from AD

                        object obVal = userProps["displayName"].Value;
                        object obAcc = userProps["sAMAccountName"].Value;


                        if (null != obVal)
                        {
                            groupMemebers.Add(obVal.ToString().ToLower());//display the display name
                            //groupMemebers.Add(obAcc.ToString());//Display the login
                        }
                        else groupMemebers.AddRange(GetGroupMembers(userProps["sAMAccountName"].Value.ToString()));

                    }
                }
            }

            catch (Exception ex)
            {
            }

            return groupMemebers;

        }

And voila, we have a list of all members of our group SharePoint!

Edit : There is another way of doing this here

Christopher.

Display ribbon on page with multiple ListViewWebPart


Hello everyone,

Today I’ll talk about a code snippet I found for a discussion on msdn. (see the discussion here: http://social.msdn.microsoft.com/Forums/en/sharepoint2010programming/thread/0372bae3-6e10-4b1f-a77a-49c892086538)

The person wanted that the behavior of a standard ListViewWebPart list remains the same even if we added other webparts on the page.

After some research I came across this tip:

http://stackoverflow.com/questions/4848892/list-tools-tab-is-no-longer-available-after-adding-webpart-to-the-page?answertab=oldest#tab-top

The proposed answer is to add a script in the page simulating a click on the ListViewWebPart.

Here’s the script:


setTimeout(function() {
    var elem = document.getElementById("MSOZoneCell_WebPartWPQ2");
    if(elem != null) {
        var dummyevent = new Array();
        dummyevent["target"] = elem;
        dummyevent["srcElement"] = elem;
        WpClick(dummyevent);
    }
}, 2000);

I tested it successfully on a team site by adding this code into a Content Editor Web Part on the page. I just changed the timeout to 2 so that it goes faster.

Well done to the person who found it!

Christopher

Developer Dashboard Overview

Hello everyone,

Today I’ll talk about the developer dashboard. This is a new feature of SharePoint 2010 which allow you to check the events of your page as SQL queries performed, the total execution time of the page, the instantiations of SPSite / SPWeb, etc.

By default this feature is disabled. To enable it you can use the following Powershell script.


$DeveloperDashboardSettings = [Microsoft.SharePoint.Administration.SPWebService]::ContentService.DeveloperDashboardSettings;
$DeveloperDashboardSettings.DisplayLevel = 'OnDemand';
$DeveloperDashboardSettings.RequiredPermissions = 'EmptyMask';
$DeveloperDashboardSettings.TraceEnabled = $true;
$DeveloperDashboardSettings.Update();

Let us look at this script.

DisplayLevel


$DeveloperDashboardSettings.DisplayLevel = 'OnDemand';

The display level can have three values : “On”,”Off”,”OnDemand”

The default is “Off”, if we set it to “On”, the dashboard will always be called and displayed at the bottom of the page. If we choose “OnDemand”, a button appears next to the welcome control (the one displaying the name of the user)

By clicking on this button, we display / hide the dashboard

RequiredPermissions


$DeveloperDashboardSettings.RequiredPermissions = 'EmptyMask';

“Required permissions” attribute is used to set the minimum rights necessary to see the dashboard. Here the value ‘EmptyMask’ allows anyone to see the dashboard.

For more information on the different masks, here is the msdn documentation : http://msdn.microsoft.com/library/microsoft.sharepoint.spbasepermissions.aspx

TraceEnabled


$DeveloperDashboardSettings.TraceEnabled = $true;

By adding this trace, we add a link in the dashboard providing us with a whole new set of information such as: The entire track, the control tree, the contents of cookies, session state and so on!


For more information on the dashboard, here is the msdn documentation: http://msdn.microsoft.com/library/ff512745.aspx

Moreover, we can add to our code a snippet to see how long it takes to run!

Let’s add the following code around the function we want to evaluate


using (new SPMonitoredScope("My tuto test"))
 {
FunctionToCheck() ;
}

This code snippet adds an entry to the dashboard.

More information about the SPMonitoredScope class on msdn: http://msdn.microsoft.com/en-us/library/ff512758.aspx

Happy debugging!

Christopher.