[DllImport("ole32.dll")]
static extern int CoQueryClientBlanket(out IntPtr pAuthnSvc, out IntPtr pAuthzSvc,
[MarshalAs(UnmanagedType.LPWStr)] out StringBuilder pServerPrincName, out IntPtr
pAuthnLevel, out IntPtr pImpLevel, out IntPtr pPrivs, out IntPtr pCapabilities);
None.
The original version of this errored with a message about memory corruption.
My modification works without error, if you use the code sample you'll need to plug in your own logging.
Please add some!
{
System.IntPtr pAthnSvc = new IntPtr();
System.IntPtr pAthzSvc = new IntPtr();
StringBuilder pServerPrincName = new StringBuilder();
System.IntPtr pAuthnLevel = new IntPtr();
System.IntPtr pImpLevel = new IntPtr();
System.IntPtr pPrivs = new IntPtr();
System.IntPtr pCaps = new IntPtr(4);
try
{
trc.Log(LOG_DEBUG, "Retrieving Principle Name");
CoQueryClientBlanket(out pAthnSvc, out pAthzSvc, out pServerPrincName, out pAuthnLevel, out pImpLevel, out pPrivs, out pCaps);
trc.Log(LOG_DEBUG, "Called CoQueryClientBlanket without error");
}
catch(Exception ex)
{
// Something went wrong, report it and then check if
//we have a valid token attached instead
trc.LogError( ex.Message ) ;
}
finally
{
// Logging the values to aid any debugging that may be required
trc.Log( LOG_DEBUG, "Values");
trc.Log( LOG_DEBUG, "pAthnSvc = " + pAthnSvc);
trc.Log( LOG_DEBUG, "pAthzSvc = " + pAthzSvc);
trc.Log( LOG_DEBUG, "pAuthnLevel = " + pAuthnLevel);
trc.Log( LOG_DEBUG, "pImpLevel = " + pImpLevel);
trc.Log( LOG_DEBUG, "pPrivs = " + pPrivs);
trc.Log( LOG_DEBUG, "pCaps = " + pCaps);
trc.Log( LOG_DEBUG, "pServerPrincName = " + pServerPrincName);
}
}
Do you know one? Please contribute it!
