see sharp RSS 2.0
# 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
# Saturday, 20 March 2010

MAC Addresses are unique to the networkcard and can be used to identify your PC.

You can view your MAC addresses by typing ipconfig /all

Ethernet adapter Loopback:
  Connection-specific DNS Suffix  . :
  Description . . . . . . . . . . . : Microsoft Loopback Adapter
  Physical Address. . . . . . . . . : 02-00-4C-4F-4F-50
  DHCP Enabled. . . . . . . . . . . : No
  Autoconfiguration Enabled . . . . : Yes
  IPv4 Address. . . . . . . . . . . :
  Subnet Mask . . . . . . . . . . . :
  Default Gateway . . . . . . . . . :
  DNS Servers . . . . . . . . . . . :
  NetBIOS over Tcpip. . . . . . . . : Enabled

to view other machines MAC addresses you can ping them and then type arp -a which wil result in a list similar to this:

Interface: --- 0xb
  Internet Address      Physical Address      Type           00-04-0e-f6-17-55     dynamic           00-04-0e-aa-88-ab     dynamic           00-01-db-09-55-42     dynamic

The first three bytes identify the manufacturer of the card, the remainder identifies the card itself. 

you can look those up here:

 I wrote a small tool that parses a file and returns the manufactuer (632.92 KB)
Saturday, 20 March 2010 12:15:35 (Mitteleuropäische Zeit, UTC+01:00)  #    -
anything else
# Friday, 19 March 2010
Friday, 19 March 2010 19:08:58 (Mitteleuropäische Zeit, UTC+01:00)  #    -

# Thursday, 11 March 2010

To enable foreign key import on a MS CA you need to set the registry accordingly:

certutil –setreg ca\KRAFlags +KRAF_ENABLEFOREIGN

then, after a restart of the CA service, you can start importing:

certutil -f -importKMS /?
  CertUtil [Options] -ImportKMS UserKeyAndCertFile [CertId]
  Import user keys and certificates into server database for key archival
    UserKeyAndCertFile -- Data file containing user private keys and certificates to be archived.  This can be any of the following:
            Exchange Key Management Server (KMS) export file
            PFX file
            Outlook key export (EPF) file
    CertId -- KMS export file decryption certificate match token.  See -store.
    Use -f to import certificates not issued by the CA.
  -f                -- Force overwrite
  -gmt              -- Display times as GMT
  -seconds          -- Display times with seconds and milliseconds
  -silent           -- Use silent flag to acquire crypt context
  -split            -- Split embedded ASN.1 elements, and save to files
  -v                -- Verbose operation
  -privatekey       -- Display password and private key data
  -config Machine\CAName    -- CA and Machine name string
  -p Password               -- Password
  -symkeyalg SymmetricKeyAlgorithm[,KeyLength] -- Name of Symmetric Key Algorithm with optional key length, example: AES,128 or 3DES
CertUtil -?              -- Display a verb list (command list)
CertUtil -ImportKMS -?   -- Display help text for the "ImportKMS" verb
CertUtil -v -?           -- Display all help text for all verbs


Thursday, 11 March 2010 08:51:53 (Mitteleuropäische Zeit, UTC+01:00)  #    -
<2012 October>
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)