see sharp RSS 2.0
# Friday, 28 February 2014

A small utility that signs federation metadata.

MetadataSigner[1].zip (56.86 KB)
it requires .NET 4.5

Friday, 28 February 2014 11:03:13 (Mitteleuropäische Zeit, UTC+01:00)  #    -
Authentication | Certificates
# Monday, 28 January 2013

There is an interesting article on how to enable tracing/logging in AD FS 2.0 on MSDN.

However the brand new Version 2.1 is located in a slightly different place:

  1. the config file is no longer located in
    %ProgramFiles%\Active Directory Federation Services 2.0\Microsoft.IdentityServer.Servicehost.exe.config 
    instead you can find it here:
  2. Configure the System.diagnostics as stated in the article
  3. the wevtutil command has to use a different Provider.
    instead of
    wevtutil sl “AD FS 2.0 Tracing/Debug” /L:5 
    you have to use:

    wevtutil sl "AD FS Tracing/Debug" /L:5

  4. restart the AD FS Service

Monday, 28 January 2013 15:11:29 (Mitteleuropäische Zeit, UTC+01:00)  #    -
Authentication | Tracing
# Monday, 10 December 2012

Much more because I tend to forget these things all the time than anything else:

NET Stop certsvc
Net Start certsvc

then you can create a INF file with the following:


Subject="CN=<your real hostname here>"


CertificateTemplate="<your templatename here>"

SAN="DNS==<your real hostname here>&DNS=<hostname1>&DNS=<hostname2>"


Monday, 10 December 2012 14:17:28 (Mitteleuropäische Zeit, UTC+01:00)  #    -
CA | Certificates | Registry
# Sunday, 07 October 2012

None. There is absolutely none.

I always suspected that but now I’m sure.

Sunday, 07 October 2012 16:04:05 (Mitteleuropäische Sommerzeit, UTC+02:00)  #    -
anything else
# Monday, 04 April 2011

i wrote about parsing the san of a certificate before, here is another way to do it:

1) add a reference to CertEnroll 1.0 Type Library

2) use IX509ExtensionAlternativeNames to get a collection of IAlternativeName objects

3) get the data using the IAlternativeName.strValue and IAlternativeName.Type attributes

 Here's an example:

private string GetSAN(X509Certificate2 cert)
        X509Extension ext = cert.Extensions[""]; // get the SAN extension

        if (null != ext)
                string temp = string.Empty;
                IX509ExtensionAlternativeNames an = new CX509ExtensionAlternativeNames();
                an.InitializeDecode(EncodingType.XCN_CRYPT_STRING_BASE64, Convert.ToBase64String(ext.RawData));
                foreach (IAlternativeName name in an.AlternativeNames)
                    temp += name.Type+":"+name.strValue+Environment.NewLine;
                return temp;                   
            catch (Exception ex)
                return ex.Message;
        return "no SAN present";
Monday, 04 April 2011 11:44:34 (Mitteleuropäische Sommerzeit, UTC+02:00)  #    -
C# | CAPI | Certificates
# Wednesday, 16 March 2011

If you have to parse the Subject Alternative Name (aka SAN) of a Certificate CertGetNameString is your friend:

[DllImport("crypt32.dll", EntryPoint = "CertGetNameString", CharSet = CharSet.Auto, SetLastError = true)]
static extern UInt32 CertGetNameString(
    IntPtr CertContext, 
    UInt32 lType, 
    UInt32 lFlags, 
    IntPtr pTypeParameter, 
    StringBuilder str, 
    UInt32 cch);

private const int CERT_NAME_EMAIL_TYPE = 1;
private const int CERT_NAME_UPN_TYPE = 8;
private const int CERT_NAME_NO_FLAG = 0;
private const int SIZE = 255;

private static void ParseSan(X509Certificate2 cc)
    Oid oid = new Oid("");
    X509Extension ext = cc.Extensions[oid.Value]; // get the SAN extension

    if (null != ext)
        StringBuilder Buffer = new StringBuilder(SIZE);               

        UInt32 nChars = CertGetNameString(cc.Handle,
        if (nChars == 1)
            nChars = CertGetNameString(cc.Handle,
        Console.WriteLine("{1}:'{0}'", Buffer.ToString(), cc.Thumbprint);

Wednesday, 16 March 2011 15:34:13 (Mitteleuropäische Zeit, UTC+01:00)  #    -
C# | CAPI | Certificates | P/INVOKE
# Thursday, 18 November 2010

You can extend the lifetime of FIM CM OTP's.

All that needs to be done is:

  • Select the Custom Password Provider option in your policy 
  • set the type to Microsoft.CLM.BusinessLayer.DefaultSecretProvider
  • the Password provider data controls the OTP generation.
    the format is in the form of
    • numberofotp can be 0,1 or two
    • i did not see a technical limit (yeah its possibly an int32, so there IS a limit) for length or lifetime


  • 1,8,40 will generate one OTP with a length of '8' and a lifetime of 40 days
  • 2.8.8,40 will generate two OTPs, both with a length of 8 and a lifetime of 40 days

It seems that adding 'm' to the lifetime will make it minutes, not days.



Thursday, 18 November 2010 11:22:46 (Mitteleuropäische Zeit, UTC+01:00)  #    -
# Wednesday, 11 August 2010

If you are working with (b)leeding edge technologies like Outlook 2007, and you have to create plugins that are to be installed for ALL users on a machine you might want to read this:

The one line I overread for (very) a long time said:

"in order for the instruction to execute we need to make sure that HKLM's Count value is different from HKCU's Count value"

So you create your settings staring with something like:

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\12.0\User Settings\<you_name_it>]



[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\12.0\User Settings\<you_name_it>\Create\Software\Microsoft\Office\Outlook\AddIns\<you_name_it_again>]

"Description"="My Fancy Plugin"

"FriendlyName"="My Fancy Plugin"


"Manifest"="[TARGETDIR]My Fancy Plugin.vsto|vstolocal"


This works perfectly unless you need to change things. Nothing gets provisioned if you just modify, lets say, the description. The following entry is causing office to ignore our

[HKEY_CURRENT_USER\SOFTWARE\Microsoft\Office\12.0\User Settings\<you_name_it>]


Provisiong only starts when the values are different, so delete the HKCU key or change its value.


Wednesday, 11 August 2010 16:14:43 (Mitteleuropäische Sommerzeit, UTC+02:00)  #    -
# Monday, 03 May 2010

Registry files can be fun, and everyone knows how to add things to the registry via reg files.

But you can also remove entries;

Prefix the key with '-' to remove it, set the value to '-' to remove it.


[-HKEY_LOCAL_MACHINE\Software\Foo] will remove the complete key 'Foo'.




will leave the key 'Foo' and remove the value 'Bar'

Keep in mind:

The registry is a central element in windows. Messing around with it may cause unpredictabele results and the whole system may fail.

So pleas double check what you are doing to the registry!!!


Monday, 03 May 2010 14:20:49 (Mitteleuropäische Sommerzeit, UTC+02:00)  #    -
# Thursday, 22 April 2010

Troubleshooting a custom MA for FIM2010 starts usually with looking into the eventlog :-)

So in this case there was not much to see, so I added my .NET Trace statments to the code. Easy, but where to configure the switches? 

Finally i found that the MA is loaded by the FIM server itself so theres the config file too.

The server is still called MIISSERVER.EXE and located in

C:\Program Files\Microsoft Forefront Identity Manager\2010\Synchronization Service\Bin

So just edit C:\Program Files\Microsoft Forefront Identity Manager\2010\Synchronization Service\Bin\miiserver.exe.config and add you listener and switches:

    <trace autoflush="true" indentsize="4">
        <add name="mylog"
             initializeData="c:\logs\mylog.log" />
      <add name="MySwitch" value="4"/>
Thursday, 22 April 2010 15:05:00 (Mitteleuropäische Sommerzeit, UTC+02:00)  #    -
FIM | Tracing
<2014 February>
About the author/Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.
Any link on this site may lead to an external website that is not under my control and that external website might show an opinion that is not mine.

© Copyright 2018
Hannes Köhler
Sign In
Total Posts: 39
This Year: 0
This Month: 0
This Week: 0
Comments: 1
All Content © 2018, Hannes Köhler
DasBlog theme 'Business' created by Christoph De Baene (delarou)