Would you like a free code sample from Microsoft?

Hi all,   Many times I get requests through my blog to provide code samples on some specific topics. Unfortunately I don’t have time to fulfill such requests. Usually the only way for me to be able to do that is if you open what we call an Advisory case with MS Technical Support, a…


ExportParameters returns Invalid type specified error

Hi all,   Some time ago a customer of mine was trying to export the private key associated to a certificate stored in a smart card, and for that he was trying to use the RSACryptoServiceProvider.ExportParameters method with a code like the following: “   System.Security.Cryptography.X509Certificates.X509Certificate2 cert = GetCert(certName); RSACryptoServiceProvider rsa = (RSACryptoServiceProvider)cert.PrivateKey; RSAParameters params =…


Get-WmiObject : The type initializer for ‘System.Management.MTAHelper’ threw an exception

Hi all,   Sometime ago a customer of mine had some problems in his x64 machine when running WMI queries in Powershell. Take for instance the following query:  ” Get-WMIObject Win32_LogicalDisk ”   It failed with the following error: ” Get-WmiObject : The type initializer for ‘System.Management.MTAHelper’ threw an exception. At line:1 char:14 + Get-WMIObject…


System.DirectoryServices.AccountManagement.UserPrincipal.IsMemberOf returns false negatives

Hi all,   Sometime ago a customer of mine faced the following issue on his .NET Framework 3.5 app: System.DirectoryServices.AccountManagement.UserPrincipal.IsMemberOf returned false negatives when the group had more than 1500 members. This means that the function returned false when the user was actually in the group. But everything worked properly with VBScript and ADSI. This turned out to…


Global hooks getting lost on Windows 7

Hi all,   Some time ago a customer of mine reported the following issue with SetWindowsHookEx API: Their application had global hooks to monitor for both keyboard and mouse input. On Windows 7, and under high CPU usage, those hooks were getting lost. They tried several things to solve the issue, without success: adjust registry setting “Control…


How does CryptoAPI order the certificates in the stores?

Hi all, The other day a customer of mine was trying to use OWA to sign an email with a specific certificate, with no success. To put you in situation, he had two certificates with very similar properties, but slightly different. When he accessed OWA, the mime control picked up the wrong cert, instead of giving them…


How to read msTSProfilePath, msTSHomeDrive and msTSHomeDirectory properties from AD (VB.NET)

  Hi all, If you used to query Active Directory properties like TerminalServicesProfilePath, TerminalServicesHomeDrive and TerminalServicesHomeDirectory on Windows Server 2003, you may have realized already that those properties are not available on Windows Server 2008 and later. If you investigate a bit, you may find some properties which are supposed to be their substitutes: msTSProfilePath,…


How to access the new Certificate Enrollment Web Services programmatically

Hi all, Some time ago a customer of mine wanted to use the Windows Server 2008 R2 Certificate Enrollment Web Services, so they could send a PKCS#10 request and get the certificate back. They followed the instructions in this whitepaper: Certificate Enrollment Web Services in Windows Server 2008 R2. They installed the CA and the…