Fixed fix path issue in CasaAuthToken c-sharp library.
This commit is contained in:
parent
8adb445805
commit
11f501db43
@ -28,52 +28,52 @@ using System.Runtime.InteropServices;
|
||||
|
||||
namespace Novell.Casa.Client.Auth
|
||||
{
|
||||
/// <summary>
|
||||
/// Summary description for Class1.
|
||||
/// </summary>
|
||||
public class Authtoken
|
||||
{
|
||||
private const string AUTH_LIBRARY = "C:\\Program Files\\Novell\\CASA\\lib\\authtoken";
|
||||
private const int BUFFER_OVERFLOW = 6;
|
||||
/// <summary>
|
||||
/// Summary description for Class1.
|
||||
/// </summary>
|
||||
public class Authtoken
|
||||
{
|
||||
private const string AUTH_LIBRARY = "casa_authtoken";
|
||||
private const int BUFFER_OVERFLOW = 6;
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
|
||||
private struct LUID
|
||||
{
|
||||
public int luidLow;
|
||||
public int luidHigh;
|
||||
}
|
||||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
|
||||
private struct LUID
|
||||
{
|
||||
public int luidLow;
|
||||
public int luidHigh;
|
||||
}
|
||||
|
||||
[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
|
||||
} ;
|
||||
[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 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
|
||||
);
|
||||
[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()
|
||||
{
|
||||
}
|
||||
|
||||
public static string ObtainAuthTokenAsString(string sService, string sHost)
|
||||
{
|
||||
@ -89,76 +89,77 @@ namespace Novell.Casa.Client.Auth
|
||||
}
|
||||
}
|
||||
|
||||
public static byte[] ObtainAuthToken(string sService, string sHost)
|
||||
{
|
||||
return ObtainAuthToken(sService, sHost, null);
|
||||
}
|
||||
public static byte[] ObtainAuthToken(string sService, string sHost)
|
||||
{
|
||||
return ObtainAuthToken(sService, sHost, null);
|
||||
}
|
||||
|
||||
private static byte[] ObtainAuthToken(string sService, string sHost, WinLuid luid)
|
||||
{
|
||||
int rcode = 0;
|
||||
byte[] baService = null;
|
||||
byte[] baHost = null;
|
||||
int bufferSize = 0;
|
||||
bool bLuidPassedIn = false;
|
||||
private static byte[] ObtainAuthToken(string sService, string sHost, WinLuid luid)
|
||||
{
|
||||
int rcode = 0;
|
||||
byte[] baService = null;
|
||||
byte[] baHost = null;
|
||||
int bufferSize = 0;
|
||||
bool bLuidPassedIn = false;
|
||||
|
||||
byte[] baToken = new byte[bufferSize];
|
||||
byte[] baToken = new byte[bufferSize];
|
||||
|
||||
// convert service to ascii byte array
|
||||
if (sService != null)
|
||||
{
|
||||
baService = Encoding.ASCII.GetBytes(sService);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("Invalid parameter");
|
||||
}
|
||||
// convert service to ascii byte array
|
||||
if (sService != null)
|
||||
{
|
||||
baService = Encoding.ASCII.GetBytes(sService);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("Invalid parameter");
|
||||
}
|
||||
|
||||
// convert host to ascii byte array
|
||||
if (sHost != null)
|
||||
{
|
||||
baHost = Encoding.ASCII.GetBytes(sHost);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("Invalid parameter");
|
||||
}
|
||||
|
||||
// convert host to ascii byte array
|
||||
if (sHost != null)
|
||||
{
|
||||
baHost = Encoding.ASCII.GetBytes(sHost);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("Invalid parameter");
|
||||
}
|
||||
|
||||
|
||||
SSCS_EXT_T ext = new SSCS_EXT_T();
|
||||
if ((luid != null) && (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));
|
||||
SSCS_EXT_T ext = new SSCS_EXT_T();
|
||||
LUID sluid;
|
||||
if ((luid != null) && (luid.GetHighPart() != 0) || (luid.GetLowPart() != 0))
|
||||
{
|
||||
// allocate a structure to marshal
|
||||
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;
|
||||
}
|
||||
Marshal.StructureToPtr(sluid, ext.ext, false);
|
||||
bLuidPassedIn = true;
|
||||
}
|
||||
|
||||
|
||||
// call with buffersize of 0. This way we determine the exact size.
|
||||
try
|
||||
{
|
||||
if (bLuidPassedIn)
|
||||
{
|
||||
rcode = ObtainAuthTokenEx(baService, baHost, baToken, ref bufferSize, ext);
|
||||
}
|
||||
else
|
||||
{
|
||||
rcode = ObtainAuthToken(baService, baHost, baToken, ref bufferSize);
|
||||
}
|
||||
|
||||
int test = (rcode & BUFFER_OVERFLOW);
|
||||
if (test == BUFFER_OVERFLOW)
|
||||
{
|
||||
// now allocate the proper size
|
||||
baToken = new byte[bufferSize];
|
||||
|
||||
// call with buffersize of 0. This way we determine the exact size.
|
||||
try
|
||||
{
|
||||
if (bLuidPassedIn)
|
||||
{
|
||||
rcode = ObtainAuthTokenEx(baService, baHost, baToken, ref bufferSize, ext);
|
||||
}
|
||||
else
|
||||
{
|
||||
rcode = ObtainAuthToken(baService, baHost, baToken, ref bufferSize);
|
||||
}
|
||||
|
||||
int test = (rcode & BUFFER_OVERFLOW);
|
||||
if (test == BUFFER_OVERFLOW)
|
||||
{
|
||||
// now allocate the proper size
|
||||
baToken = new byte[bufferSize];
|
||||
if (bLuidPassedIn)
|
||||
{
|
||||
rcode = ObtainAuthTokenEx(baService, baHost, baToken, ref bufferSize, ext);
|
||||
@ -167,30 +168,30 @@ namespace Novell.Casa.Client.Auth
|
||||
{
|
||||
rcode = ObtainAuthToken(baService, baHost, baToken, ref bufferSize);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LogMessage(e.ToString());
|
||||
return null;
|
||||
}
|
||||
|
||||
if (ext.ext != IntPtr.Zero)
|
||||
Marshal.FreeHGlobal(ext.ext);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LogMessage(e.ToString());
|
||||
return null;
|
||||
}
|
||||
|
||||
if (ext.ext != IntPtr.Zero)
|
||||
Marshal.FreeHGlobal(ext.ext);
|
||||
|
||||
if (rcode != 0)
|
||||
{
|
||||
throw new Exception(rcode.ToString());
|
||||
}
|
||||
else
|
||||
{
|
||||
return baToken;
|
||||
}
|
||||
}
|
||||
if (rcode != 0)
|
||||
{
|
||||
throw new Exception(rcode.ToString());
|
||||
}
|
||||
else
|
||||
{
|
||||
return baToken;
|
||||
}
|
||||
}
|
||||
|
||||
private static void LogMessage(string sMessage)
|
||||
{
|
||||
System.Diagnostics.Trace.WriteLine("(C#)AuthToken: " + sMessage);
|
||||
}
|
||||
}
|
||||
private static void LogMessage(string sMessage)
|
||||
{
|
||||
System.Diagnostics.Trace.WriteLine("(C#)AuthToken: " + sMessage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@
|
||||
Version="8.00"
|
||||
Name="test"
|
||||
ProjectGUID="{6034EBF1-0838-45C4-A538-A41A31EC8F46}"
|
||||
RootNamespace="test"
|
||||
Keyword="Win32Proj"
|
||||
>
|
||||
<Platforms>
|
||||
@ -62,10 +63,10 @@
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="authtoken.lib ws2_32.lib"
|
||||
AdditionalDependencies="casa_authtoken.lib ws2_32.lib"
|
||||
OutputFile="$(OutDir)/test.exe"
|
||||
LinkIncremental="2"
|
||||
AdditionalLibraryDirectories=""C:\Program Files\novell\CASA\lib""
|
||||
AdditionalLibraryDirectories=""C:\Program Files\novell\CASA\lib";"C:\Dev\casa\CASA-auth-token\client\lib\windows""
|
||||
GenerateDebugInformation="true"
|
||||
ProgramDatabaseFile="$(OutDir)/test.pdb"
|
||||
SubSystem="1"
|
||||
@ -94,7 +95,7 @@
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
CommandLine="copy ..\..\windows\debug\authtoken.dll debug\authtoken.dll"
|
||||
CommandLine="copy ..\..\windows\debug\casa_authtoken.dll debug\casa_authtoken.dll"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
@ -142,7 +143,7 @@
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="authtoken.lib ws2_32.lib"
|
||||
AdditionalDependencies="casa_authtoken.lib ws2_32.lib"
|
||||
OutputFile="$(OutDir)/test.exe"
|
||||
LinkIncremental="1"
|
||||
AdditionalLibraryDirectories=""C:\Program Files\novell\CASA\lib""
|
||||
|
@ -67,7 +67,7 @@
|
||||
IgnoreImportLibrary="false"
|
||||
AdditionalOptions="/EXPORT:ObtainAuthToken /EXPORT:ObtainAuthTokenEx"
|
||||
AdditionalDependencies="ws2_32.lib winhttp.lib libexpatml.lib micasa.lib shlwapi.lib"
|
||||
OutputFile="$(OutDir)/authtoken.dll"
|
||||
OutputFile="$(OutDir)/casa_authtoken.dll"
|
||||
LinkIncremental="1"
|
||||
AdditionalLibraryDirectories=""\Program Files\Microsoft Platform SDK\lib";"\Program Files\Novell\CASA\lib";"C:\Dev\Expat-2.0.0\StaticLibs""
|
||||
IgnoreAllDefaultLibraries="false"
|
||||
@ -151,7 +151,7 @@
|
||||
Name="VCLinkerTool"
|
||||
AdditionalOptions="/EXPORT:ObtainAuthToken /EXPORT:ObtainAuthTokenEx"
|
||||
AdditionalDependencies="ws2_32.lib winhttp.lib libexpatml.lib micasa.lib shlwapi.lib"
|
||||
OutputFile="$(OutDir)/authtoken.dll"
|
||||
OutputFile="$(OutDir)/casa_authtoken.dll"
|
||||
LinkIncremental="1"
|
||||
AdditionalLibraryDirectories=""\Program Files\Microsoft Platform SDK\lib";"\Program Files\Novell\CASA\lib";"C:\Dev\Expat-2.0.0\StaticLibs""
|
||||
IgnoreDefaultLibraryNames="libc"
|
||||
|
@ -34,13 +34,19 @@
|
||||
"Entry"
|
||||
{
|
||||
"MsmKey" = "8:_71C343EBC4935F8914C3145115EDEC4A"
|
||||
"OwnerKey" = "8:_C1C37E2154994C29B02FDD9C90635B26"
|
||||
"OwnerKey" = "8:_8E623C85FD4143F3B09460457E8ED6CA"
|
||||
"MsmSig" = "8:_UNDEFINED"
|
||||
}
|
||||
"Entry"
|
||||
{
|
||||
"MsmKey" = "8:_71C343EBC4935F8914C3145115EDEC4A"
|
||||
"OwnerKey" = "8:_8E623C85FD4143F3B09460457E8ED6CA"
|
||||
"OwnerKey" = "8:_C1C37E2154994C29B02FDD9C90635B26"
|
||||
"MsmSig" = "8:_UNDEFINED"
|
||||
}
|
||||
"Entry"
|
||||
{
|
||||
"MsmKey" = "8:_75519C9025D94CC496F276E698CE3AF8"
|
||||
"OwnerKey" = "8:_UNDEFINED"
|
||||
"MsmSig" = "8:_UNDEFINED"
|
||||
}
|
||||
"Entry"
|
||||
@ -487,6 +493,34 @@
|
||||
{
|
||||
}
|
||||
}
|
||||
"{5259A561-127C-4D43-A0A1-72F10C7B3BF8}:_75519C9025D94CC496F276E698CE3AF8"
|
||||
{
|
||||
"SourcePath" = "8:..\\..\\..\\lib\\windows\\Debug\\casa_authtoken.dll"
|
||||
"TargetName" = "8:"
|
||||
"Tag" = "8:"
|
||||
"Folder" = "8:_E092F841E4D04920B053C3F6A5151BA2"
|
||||
"Condition" = "8:"
|
||||
"Transitive" = "11:FALSE"
|
||||
"Vital" = "11:TRUE"
|
||||
"ReadOnly" = "11:FALSE"
|
||||
"Hidden" = "11:FALSE"
|
||||
"System" = "11:FALSE"
|
||||
"Permanent" = "11:FALSE"
|
||||
"SharedLegacy" = "11:FALSE"
|
||||
"PackageAs" = "3:1"
|
||||
"Register" = "3:1"
|
||||
"Exclude" = "11:FALSE"
|
||||
"IsDependency" = "11:FALSE"
|
||||
"IsolateTo" = "8:"
|
||||
"ProjectOutputGroupRegister" = "3:1"
|
||||
"OutputConfiguration" = "8:"
|
||||
"OutputGroupCanonicalName" = "8:Built"
|
||||
"OutputProjectGuid" = "8:{7BD9A5DB-DE7D-40B7-A397-04182DC2F632}"
|
||||
"ShowKeyOutput" = "11:TRUE"
|
||||
"ExcludeFilters"
|
||||
{
|
||||
}
|
||||
}
|
||||
"{5259A561-127C-4D43-A0A1-72F10C7B3BF8}:_8E623C85FD4143F3B09460457E8ED6CA"
|
||||
{
|
||||
"SourcePath" = "8:..\\..\\..\\lib\\mechanisms\\pwd\\windows\\Debug\\pwmech.dll"
|
||||
@ -517,7 +551,7 @@
|
||||
}
|
||||
"{5259A561-127C-4D43-A0A1-72F10C7B3BF8}:_C1C37E2154994C29B02FDD9C90635B26"
|
||||
{
|
||||
"SourcePath" = "8:..\\..\\..\\lib\\windows\\Debug\\authtoken.dll"
|
||||
"SourcePath" = "8:..\\..\\..\\lib\\windows\\Debug\\casa_authtoken.dll"
|
||||
"TargetName" = "8:"
|
||||
"Tag" = "8:"
|
||||
"Folder" = "8:_01897726E7804A3B875B67A1C2692147"
|
||||
|
Loading…
Reference in New Issue
Block a user