onsdag 23 september 2009


Warning! This note only makes sense for the Dynamics Ax developers out there. Specifically if you are setup up Enterprise Portal or something similar that uses the .Net Business Connector to connect to Ax.

A simple tool for verifying if you have a working Business Connector .Net setup.

Download it here. To run it you need the 13MB Microsoft.Dynamics.BusinessConnectorNet.dll, version 5.0.1 (2009, SP1) in the program directory.

Basically the code looks like this:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Dynamics.BusinessConnectorNet;

namespace BusinessConnectorTest
class Program
static void Main(string[] args)
Microsoft.Dynamics.BusinessConnectorNet.Axapta DynAx = new Microsoft.Dynamics.BusinessConnectorNet.Axapta();
Microsoft.Dynamics.BusinessConnectorNet.AxaptaRecord DynRec;

DynAx.Logon(null, null, null, null);
Console.WriteLine("Logon successful!");

DynRec = DynAx.CreateAxaptaRecord("CustTable");
Console.WriteLine("Create record successful!");

DynRec.ExecuteStmt("select firstonly * from %1");
Console.WriteLine("Select successful!");
Console.WriteLine(string.Format("Recid: {0}", DynRec.get_Field("RECID")));
catch (Exception ex)

Very simple, but still handy to have. The catch is the good part :). Gives you an idea of what is wrong.

This code uses the current user to logon. Use "runas" to change user.

fredag 11 september 2009

Find out the name of the AD server

Ever wondered which machine is the AD server of the machine you are using?

echo %logonserver%

Will tell you the machine name of the AD server or simply give you the current machine name back if you are not connected to a domain.

torsdag 10 september 2009


The lovely little tool setspn...

It has different command for different versions (new commands in windows server 2008).

It has very little error checking so it allows you to register duplicate SPN's which will ruin your kerberos authentication.

The nice view command "setspn -l " allows you to specify both a machine or a user as argument. The results are different and does not show the same information.


tisdag 8 september 2009

Verify Kerberos in a SQL Server installation

Use the SQL Server Management Studio, connect to the server (note you must NOT do this locally on the server). Execute this T-SQL:

SELECT auth_scheme FROM sys.dm_exec_connections WHERE session_id = @@spid;

It will return either "NTLM" or "KERBEROS".

More on Kerberos will follow...

lördag 4 april 2009

DYM - Did You Mean?

I coded a web part to present the user with "Did you mean ...?" suggestions in Microsoft Search Server Express. For more information see the complete web part information at my home page. http://www.albert.nu/programs/dym

onsdag 1 april 2009

WSS safe upload hack

Find the upload.aspx file in 12\TEMPLATE\LAYOUTS and change the "OverwriteSingle" checkbox to this:

...asp:CheckBox id="OverwriteSingle" Visible="false" Checked="false"...

The checkbox will not be visible and if a duplicate document is selected the user will get an error instead of overwriting the existing file.

NOTE: This is hack of the standard out of the box solution.

onsdag 18 mars 2009

Stored procedure result into a table...

Needed to kill a large range of spid's today... but how can that be done in a simple and flexible way?

Well, put the result of sp_who2 into a table, do a select from that table to generate one column with the text 'kill '. And then copy paste the result and run it.

declare @sp_who table
spid smallint,
status nchar(30),
loginame nchar(128),
hostname nchar(128),
blkby char(5),
dbname nchar(128),
cmd nchar(16),
cputime int,
diskio int,
lastbatch varchar(20),
program nchar(128),
spid2 smallint,
requestid int

insert into @sp_who execute sp_who2

select * from @sp_who

Modify the final select to suit your needs.

lördag 7 mars 2009

WSS Create Discussion Board item

Creating and manipulating ordinary lists in WSS through the object model is easy, and finding examples on the web is also easy. But what about discussion boards?

Turns out that they are not as easily manipulated, and examples are very hard to find. After much browsing I found this information though:

Use this code:
using Microsoft.Sharepoint.Utilities;

SPListItem item = SPUtility.CreateNewDiscussion(.Items, "");
item["Body"] = "";

There is a corresponding method to add discussion replies:

tisdag 3 mars 2009

BizTalk installation/configuration

During the installation of BAM Tools you have an option to "Enable Analysis Services for BAM aggregations". When I tried to configure BizTalk the other day this part simply wouldn't work.

The error displayed looked like this:
Either the '' user does not have permission to create a new object in '', or the object does not exist.

This seemed odd to me because the previous parts of the configuration had successfully created several databases with the same user account.

So what's the problem then? Almost embarrasing... analysis services uses its own port, not the standard 1433 sql server port. So after add the required port to the firewall rules everything worked as expected.

onsdag 21 januari 2009

Use SQL Server trace to find problems on other servers!

The trace tool in SQL Server is mostly used to find performance problems related to SQL Server. But it is also a great tool to find performance problems in application servers and web servers.

The general way of thinking is this: Even if your SQL Server is doing fine what impact does the information flow have on other parts of the system? It is not unusual that the SQL Server is the most powerful machine in the system, allowing it to cope with huge loads of requests.

If you see either large amounts of requests to SQL Server or fewer requests but with large amounts of data try to figure out how the application manages this information. The life of an application server is not that simple, by knowing the SQL Server requests you can figure out what it is doing and maybe make it easier on both the application server and SQL Server.