Archive for the ‘x64’ Category

You’ve set up the User Profile Synchronisation using the Microsoft Documentation, and your now at the situation where have the Active Directory Accounts imported into SharePoint. Now, you want to do a data load and match up people picker fields to the actual profiles in the SharePoint format of ID;#FirstName LastName. However, to do this you need to find out what the Id of each user is.

So, here how I went about getting them.

Firstly, the profile import throws all the users into the Profile DB you have set up in the previous step. So, open SQL Server Management Studio –> Profile DB and return all the user profile records by running the following query

Insert List Item Method

SELECT [PreferredName] ,[Email]

FROM [Profile DB].[dbo].[UserProfile_Full]

Next step is to copy all the returned email addresses into a file and save it somewhere, were going to use the data in a minute.

Now create an console application, remembering to set the framework to 3.5 and the target processor to x64 as I’ve described in a previous blog.

Now, add the text file to the root of the project as an embedded resource.

and the copy in the following code into your program.cs . You will need to change the constant values to suit your environment and add

Compile the exe, copy it your server and run it as administrator and it should populate the output file in a comma separated list with the ids which are in use.

However, there is one snag.

SPWeb.AllUsers only returns the user who have actual been parsed in the site. So, to get round this, create a new column on list as a people picker and allow it to hold multiple values. Then, take your list of AD users, who don’t have Id yet and copy them into the people picker and save the list item. This should now create id for those users. I’m not sure if there is a limit for the people picker fields but I successfully added 30. Massive domains may be a bit harder though.

Rather than building something which had to be deployed to SharePoint which was of no use to the application. I decided it would be easier to just, quickly, build a console application to get some values and write them to a file. This was the way I had done it before using MOSS. However, when I did this on the Sharepoint 2010, it complained with FileNotFoundException. As can be seen in the image below.

This puzzled me at first, but after some digging I found that not only do you have to change the .NET Framework version to 3.5, but you also have to set the platform target to x64. This is done from the build tab of the project properties.

Once you know, it makes sense, but at first it caused a little confusion!