Category: Microsoft

Eat your own spreadsheet?

Today i was using google apps to do some stuff for a customer of Nettrends. I had to create lots of user accounts, well, lots.. it was too much to type.

Google apps supports this by allowing you to upload a CSV file. I read the description about it (yeah, i do that…)
Then i found this:

Make a list of user accounts

You'll need to create a CSV (comma separated value) file with the user account information. Spreadsheet programs like Microsoft Excel make it easy to create and edit CSV files.

So, google APPS advices you to use Microsoft Excel. So much for eat your own dogfood!

Creating a K2 Deployment Package from code

In our current project, we are using Tean Foundation Server to automate our build process. This also means MSI’s are created for every artifact to deploy, eventually using TFS’s functionality to deploy a new msi when the build quality is changed. MSI’s are build in a way so they can be installed from command line without user actions required (unattended installation). So, when we change the build quality of a build it can fully automatically be deployed to a testing environment.

Most of our software that needs to be deployed are webservices, websites or web parts. K2 however, is somewhat harder to deploy. Since BlackPearl it has become a lot easier because you can use a MSBUILD command to deploy a process. For those of you who don’t know about this. Check out KB000188 at the K2 Knowledge base. In general, it comes down to this command:

MSBUILD DeploymentPackage.msbuild /p: Environment=Development

It’s easy to create a MSI or (PowerShell) script that starts the MSBUILD command and installs the process. But how do we automate the creation of the deployment package? Since this is normally done from VS2005.

Building/deploying using code

The solution is actually quite easy, but we’ll get to that later. First off all k2 developers should have a copy of the developer reference. This documentation is still work in progress but there is a lot of information already in there. It also has an example on how to deploy a process using code. This utilizes the DeploymentPackage and Sourcecode.Framework.ProjectSystem.Project class. So the msbuild command can actually be replaced with a custom-coded application, which is even nicer for a msi than just kicking of a msbuild command.
The deploymentPackage is produced using the Project.CreateDeploymentPackage(). From the function name you’d expect it to do the same as the VS2005 context menu. It however does not.

Creating the deployment package

So if the CreateDeploymentPackage() doesn’t create the deployemtn package, what does? Well, simple, the Save() method of the Project. It takes in two parameters. The directory where to save the deployment package and the name of the deployment package.
The result is the same file/folder structure as it is described in the KB000188 article.

Great! Now why is this article longer?

Well, from what I’ve found, the code in the developer reference does not export the environment variables and so the Project.Save() method does not give you any environment information. This also results in a empty stringtables section when you use the Developer reference example code.

From what I can find out, the environment settings need to be added to the package itself.
Since the K2 api is so nice to code agains, this results in the following method:

private void AddEnvironment(DeploymentPackage package, string SelectedEnvironment) {
  EnvironmentSettingsManager envManager = new EnvironmentSettingsManager(true);
  envManager.ConnectToServer(this.K2ConnectionString);
  envManager.InitializeSettingsManager(true);
  envManager.Refresh();

  //Add environments + environment properties.
  foreach (EnvironmentTemplate envTemp in envManager.EnvironmentTemplates)
  {
    foreach (EnvironmentInstance envInst in envTemp.Environments)
    {
      //Add an environment to the package.
      DeploymentEnvironment env = package.AddEnvironment(envInst.EnvironmentName);
      foreach (EnvironmentField field in envInst.EnvironmentFields)
      {
        env.Properties[field.FieldName] = field.Value;
      }

      // Make sure the environment we select actually exists.
      if (envInst.EnvironmentName == SelectedEnvironment)
      {
        package.SelectedEnvironment = envInst.EnvironmentName;
      }
    }
  }

  //Cleanup
  envManager.Disconnect();
  envManager = null;

  //Final check of the selected environment
  if (package.SelectedEnvironment == null || package.SelectedEnvironment == string.Empty)
  {
    throw new Exception(string.Format("Could not find the environment you wanted to select ({0})", SelectedEnvironment));
  }
}

The above method adds the environment fields to the DeploymentPackage. The DeploymentPackage is part of the Project and if we deploy the project now, the environment settings are exported to the server. This also means when we call the .Save() method, the environment settings are stored inside the .msbuild script that the .Save() method produces.
The environment manager can be located in the SourceCode.EnvironmentSettings.Client assembly and the ConnectionString used is retrieved from the SourceCode.Hosting.Client.BaseAPI.SCConnectionStringBuilder object.

And voila, a deployment package is created using code!

Download!

I’m still working on a final version that creates the deployment package using a MS build task, this MSBuild task will be added to the TFS build so the TFS build on the build server creates the deployment packages. This is done by inheriting from the Task object.
The attached file is a example on how to do that. The code works, but i’m still having small issues to getting it work on the TFS server itself. Nevertheless, you can use the class to create your own command line tool to deploy the process.

SharePoint Conference Seattle, Day 4

So, the conference has already been finished for a few days. I still have some comments about Day 4 around.

IBP302 – Managing the Data in your database using the DataView Web Part… No Code Needed!

This session got my attention because of the No Code Needed and because “normally” data is provided to sharepoint using the BDC. I’ve also used the DataView Web Part to show list data in a different format using XSLT. I knew you could do databases but not that you can edit data entries. Eventually this looks a lot like the DataGridView like you get with normal ASPX applications, only rendering is done using XSLT and you can have different sources (like SPLists). The functionality provided is very powerful and easy to create. For simple database activities this is very nice. A thing I don’t like that this is all done in SharePoint designer. This isn’t really handy for deploying to a customer location using a SharePoint Solution/Feature. There must be some good way to do this, but I haven’t looked into it. We’ll probably end up copy and pasting the ASPX files into a Custom Site Pages project that was shown the day before. This isn’t very nice but it still provides easy development within SharePoint Designer.

There are some small cases where the data editing fails because of data type transformation. This can be solved by changing the CommandSync attribute to false in the code of the data connection. This can all be found in the code view of SharePoint Designer. The command allows you to edit the SQL statement and do a convert() function in the SQL statement.

AG400 – Security under the hood in Microsoft Sharepoint Products and Technologies

This was the second session that I attended from Ted Pattision. The man always speaks very fast and this was again the case. Nevertheless, he provides loads of information and again this session was very useful.

The first thing that Ted does is create a new site using STSADM. If you use the UI you will get extra SharePoint groups. With STSADM you do not. Then he started up MS Access to retrieve information from a SharePoint List. The fun thing about MS Access is that it will not obey the hidden property of a list and simply show it. Now you can view the User list of SharePoint. This list is located on every site and holds the users that are allowed on the site. When you add groups a group is shown in the list. If you add a group and then access the sharepoint site from a user in that group, the user gets added to the hidden user list. This is for auditing, hence you would only know the group. SharePoint Permissions are inherited throughout the site, list and item level. Until you break the inheritance. This also shows a SHAREPOINT\System user that is always available. The SHAREPOINT\System group is used to mask the IIS identity that is really used. This helps security on the front-end. As a SharePoint user you will not know what IIS Identity is used. If you want to do things as that user in code, you should use the RunWithElevatedPrivileges.

The session then went on to show how form authentication works and what you should do to set it up. This also showed how Zones work and what they do. If you want to have Forms authentication and normal AD integration, then you need two zones. For the form based authentication you’ll need a database to store users and passwords. This can be done using the aspnet_regsql.exe program. This simply creates the database that is used when you use the normal ASP.net authentication provider out of the box. You only need two tables from the database, but it’s more easy to create them with the aspnet_regsql.exe program.

Then there was another session to this section, although all permissions are done on a site collection level and inherited. You cannot deny a user access. This can be done within central administration under Web Application Policy settings. Basically the policies defined there overrule the site collection settings.

ECMS207 – MOSS Meets DOD Certification

As you might know, sharepoint has done a DOD 1505.2 certification program. This session was about the (free) add-on package that enables a new record center that is DOD 1505.2 certified. A lot of features where added to do this, downside was that the OOTB record center isn’t available anymore.
Some things that I got from the presentation:

  • Records get a unique ID
  • Non-electronic documents can be stored. This basically provides a stub for a real document.
  • Categories are added so records can be placed in a category
  • The category provides the retention policy etc etc.
  • Search Improvements (search within you search query, different result page, no managed properties needed)
  • Records can be related so it is clear they belong together
  • Security can be based on record category

Conclusion/Final notes

Although this was the last day, some nice sessions where held and it was good seeing those being continued to the end. The event didn’t have a real last session or keynote at the end which wasn’t that nice. In general there was loads of information and I can’t wait to try stuff myself!

Also, it is nice to see that people are actually reading this. This can lead to funny situations at K2 Bar-drinking-events :P

WordPress Themes