tags:

views:

212

answers:

2

I have somehow come out with a signature for this api call, but the call does not work in the expected fashion. Some vital data structures are not get populated properly hence I am not getting intended output. The signature I've used is:

[DllImport("secur32.dll", SetLastError = true)]
    static extern ulong AcquireCredentialsHandle(
        string pszPrincipal,
        string pszPackage,
        ulong fCredentialsUse,
        IntPtr pvLogonID,
        ref SEC_WINNT_AUTH_IDENTITY pAuthData, 
        //IntPtr pAuthData,
        IntPtr pGetKeyFn,
        IntPtr pGetArgumentKey,
        //ref SecHandle phCredential,
        IntPtr phCredential,
        ref TimeStamp ptsExpiry);

Please ignore the comments.

The c-based function call I used for reference can be found here. I want to know what did I do wrong...

+2  A: 

Did you tried this at pinvoke.net?

Oliver
+1  A: 

From pInvoke.net

[StructLayout(LayoutKind.Sequential)]
public struct SECURITY_INTEGER
{
    public uint LowPart;
    public int HighPart;
    public SECURITY_INTEGER(int dummy)
    {
    LowPart = 0;
    HighPart = 0;
    }
};

[StructLayout(LayoutKind.Sequential)]
public struct SECURITY_HANDLE
{
    public uint LowPart;
    public uint HighPart;
    public SECURITY_HANDLE(int dummy)
    {
    LowPart = HighPart = 0;
    }
};


[DllImport("secur32.dll", SetLastError=true)]
  static extern int AcquireCredentialsHandle(
    string pszPrincipal, //SEC_CHAR*
    string pszPackage, //SEC_CHAR* //"Kerberos","NTLM","Negotiative"
    int fCredentialUse,
    IntPtr PAuthenticationID,//_LUID AuthenticationID,//pvLogonID, //PLUID
    IntPtr pAuthData,//PVOID
    int pGetKeyFn, //SEC_GET_KEY_FN
    IntPtr pvGetKeyArgument, //PVOID
    ref SECURITY_HANDLE phCredential, //SecHandle //PCtxtHandle ref
    ref SECURITY_INTEGER ptsExpiry); //PTimeStamp //TimeStamp ref
blowdart