Hi,
I'm currently trying to implement a Sub Authentication package for kerberos logons, and this requires getting Windows to call a DLL of mine (by entering the DLL name in a specific registry entry). I know ideally this should be in unmanaged C++ but as I only know VB.NET I'm trying to do it from that as I've done plenty of P/Invoke from it in the past. I've used a utility to export the function signature so that unmanaged code (the Windows logon process in this case) can call it, and I know that part is working fine as I can see my function is actually being called because I have it write the current time to a text file and that text file is indeed being updated every time a logon attempt takes place on the domain. However, the problem is that I don't seem to be returning the correct value as it acts as if I've returned an error code and therefore refuses to let anyone logon.
The documentation on MSDN for this function I've implemented in my .NET DLL is here (Msv1_0SubAuthenticationFilter: http://msdn.microsoft.com/en-gb/library/windows/desktop/aa378751(v=vs.85).aspx) and as you can see it says to just return STATUS_SUCCESS if you want to indicate that the logon validation was successful. According to everything I can find an NTSTATUS type is just a LONG really, and the platform invoke description here (http://msdn.microsoft.com/en-US/library/ac7ay120(v=vs.80).aspx) says a Long should just be an Int32 in .NET. So as I want to return STATUS_SUCCESS I just return 0 but as mentioned in the previous paragraph that doesn't seem to work. Do I need to marshal the Int32 that I'm returning back in some way?
Here's how I've currently got the method signature declared:
<DllExport()> _ Public Shared Function Msv1_0SubAuthenticationFilter(ByVal LogonLevel As UInt32, ByVal LogonInformation As IntPtr, ByVal Flags As UInteger, ByVal UserAll As IntPtr, ByRef WhichFields As UInteger, ByRef UserFlags As UInteger, ByRef Authoritative As Byte, ByRef LogoffTime As LARGE_INTEGER, ByRef KickoffTime As LARGE_INTEGER) As UInteger
I was originally returning a regular signed 32 bit integer but as you can see I've now changed that to an unsigned 32 bit integer just to test but that didn't make any difference.
Any ideas where I'm going wrong?
Thanks
Chris
My website (free apps I've written for IT Pro's) : www.cjwdev.co.uk My blog: cjwdev.wordpress.com