Support for DLU by allowing luid's to be passed by the system process.
This commit is contained in:
parent
3f093e092d
commit
39fdc355c7
@ -36,15 +36,39 @@ namespace Novell.Casa.Client.Auth
|
|||||||
private const string AUTH_LIBRARY = "C:\\Program Files\\Novell\\CASA\\lib\\authtoken";
|
private const string AUTH_LIBRARY = "C:\\Program Files\\Novell\\CASA\\lib\\authtoken";
|
||||||
private const int BUFFER_OVERFLOW = 6;
|
private const int BUFFER_OVERFLOW = 6;
|
||||||
|
|
||||||
[DllImport(AUTH_LIBRARY, CharSet=CharSet.None) ]
|
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
|
||||||
public static extern int ObtainAuthToken
|
public struct LUID
|
||||||
(
|
{
|
||||||
[In] byte[] baService,
|
public int luidLow;
|
||||||
[In] byte[] baHost,
|
public int luidHigh;
|
||||||
[In, Out] byte[] baToken,
|
}
|
||||||
[In, Out] ref int iTokenLength
|
|
||||||
);
|
|
||||||
|
|
||||||
|
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
|
||||||
|
public class SSCS_EXT_T
|
||||||
|
{
|
||||||
|
public int extID = 0; // defined to identify the extension
|
||||||
|
public int version = 0; // defined as the version of the specified extension
|
||||||
|
public IntPtr ext; // points to the actual extension
|
||||||
|
} ;
|
||||||
|
|
||||||
|
[DllImport(AUTH_LIBRARY, CharSet=CharSet.None) ]
|
||||||
|
private static extern int ObtainAuthToken
|
||||||
|
(
|
||||||
|
[In] byte[] baService,
|
||||||
|
[In] byte[] baHost,
|
||||||
|
[In, Out] byte[] baToken,
|
||||||
|
[In, Out] ref int iTokenLength
|
||||||
|
);
|
||||||
|
|
||||||
|
[DllImport(AUTH_LIBRARY, CharSet=CharSet.None) ]
|
||||||
|
private static extern int ObtainAuthTokenEx
|
||||||
|
(
|
||||||
|
[In] byte[] baService,
|
||||||
|
[In] byte[] baHost,
|
||||||
|
[In, Out] byte[] baToken,
|
||||||
|
[In, Out] ref int iTokenLength,
|
||||||
|
[In] SSCS_EXT_T ext
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
public Authtoken()
|
public Authtoken()
|
||||||
@ -53,11 +77,17 @@ namespace Novell.Casa.Client.Auth
|
|||||||
|
|
||||||
|
|
||||||
public static byte[] ObtainAuthToken(string sService, string sHost)
|
public static byte[] ObtainAuthToken(string sService, string sHost)
|
||||||
|
{
|
||||||
|
return ObtainAuthToken(sService, sHost, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static byte[] ObtainAuthToken(string sService, string sHost, WinLuid luid)
|
||||||
{
|
{
|
||||||
int rcode = 0;
|
int rcode = 0;
|
||||||
byte[] baService = null;
|
byte[] baService = null;
|
||||||
byte[] baHost = null;
|
byte[] baHost = null;
|
||||||
int bufferSize = 0;
|
int bufferSize = 0;
|
||||||
|
bool bLuidPassedIn = false;
|
||||||
|
|
||||||
byte[] baToken = new byte[bufferSize];
|
byte[] baToken = new byte[bufferSize];
|
||||||
|
|
||||||
@ -82,10 +112,34 @@ namespace Novell.Casa.Client.Auth
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
SSCS_EXT_T ext = new SSCS_EXT_T();
|
||||||
|
if ((luid.GetHighPart() != 0) || (luid.GetLowPart() != 0))
|
||||||
|
{
|
||||||
|
// allocate a structure to marshal
|
||||||
|
LUID sluid = new LUID();
|
||||||
|
sluid.luidHigh = luid.GetHighPart();
|
||||||
|
sluid.luidLow = luid.GetLowPart();
|
||||||
|
|
||||||
|
ext.extID = 1;
|
||||||
|
ext.version = 1;
|
||||||
|
ext.ext = Marshal.AllocHGlobal(Marshal.SizeOf(sluid));
|
||||||
|
|
||||||
|
Marshal.StructureToPtr(sluid, ext.ext, false);
|
||||||
|
bLuidPassedIn = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// call with buffersize of 0. This way we determine the exact size.
|
// call with buffersize of 0. This way we determine the exact size.
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
rcode = ObtainAuthToken(baService, baHost, baToken, ref bufferSize);
|
if (bLuidPassedIn)
|
||||||
|
{
|
||||||
|
rcode = ObtainAuthTokenEx(baService, baHost, baToken, ref bufferSize, ext);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
rcode = ObtainAuthToken(baService, baHost, baToken, ref bufferSize);
|
||||||
|
}
|
||||||
|
|
||||||
int test = (rcode & BUFFER_OVERFLOW);
|
int test = (rcode & BUFFER_OVERFLOW);
|
||||||
if (test == BUFFER_OVERFLOW)
|
if (test == BUFFER_OVERFLOW)
|
||||||
@ -101,6 +155,8 @@ namespace Novell.Casa.Client.Auth
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ext.ext != IntPtr.Zero)
|
||||||
|
Marshal.FreeHGlobal(ext.ext);
|
||||||
|
|
||||||
if (rcode != 0)
|
if (rcode != 0)
|
||||||
{
|
{
|
||||||
|
@ -93,6 +93,11 @@
|
|||||||
SubType = "Code"
|
SubType = "Code"
|
||||||
BuildAction = "Compile"
|
BuildAction = "Compile"
|
||||||
/>
|
/>
|
||||||
|
<File
|
||||||
|
RelPath = "WinLuid.cs"
|
||||||
|
SubType = "Code"
|
||||||
|
BuildAction = "Compile"
|
||||||
|
/>
|
||||||
</Include>
|
</Include>
|
||||||
</Files>
|
</Files>
|
||||||
</CSHARP>
|
</CSHARP>
|
||||||
|
@ -0,0 +1,29 @@
|
|||||||
|
using System;
|
||||||
|
|
||||||
|
namespace Novell.Casa.Client.Auth
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Summary description for WinLuid.
|
||||||
|
/// </summary>
|
||||||
|
public class WinLuid
|
||||||
|
{
|
||||||
|
private int m_low = 0;
|
||||||
|
private int m_high = 0;
|
||||||
|
|
||||||
|
public WinLuid(int lowPart, int highPart )
|
||||||
|
{
|
||||||
|
m_low = lowPart;
|
||||||
|
m_high = highPart;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int GetLowPart()
|
||||||
|
{
|
||||||
|
return m_low;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int GetHighPart()
|
||||||
|
{
|
||||||
|
return m_high;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -48,6 +48,10 @@ namespace TestClientAuth
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
||||||
|
WinLuid luid = new WinLuid(1234, 5678);
|
||||||
|
Authtoken.ObtainAuthToken("testService", args[0], luid);
|
||||||
|
|
||||||
byte[] baToken = Authtoken.ObtainAuthToken("testService", args[0]);
|
byte[] baToken = Authtoken.ObtainAuthToken("testService", args[0]);
|
||||||
Console.WriteLine("Token returned: ("+ baToken.Length + ")");
|
Console.WriteLine("Token returned: ("+ baToken.Length + ")");
|
||||||
for (int i=0; i<baToken.Length; i++)
|
for (int i=0; i<baToken.Length; i++)
|
||||||
|
Loading…
Reference in New Issue
Block a user