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
|
namespace Novell.Casa.Client.Auth
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Summary description for Class1.
|
/// Summary description for Class1.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class Authtoken
|
public class Authtoken
|
||||||
{
|
{
|
||||||
private const string AUTH_LIBRARY = "C:\\Program Files\\Novell\\CASA\\lib\\authtoken";
|
private const string AUTH_LIBRARY = "casa_authtoken";
|
||||||
private const int BUFFER_OVERFLOW = 6;
|
private const int BUFFER_OVERFLOW = 6;
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
|
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
|
||||||
private struct LUID
|
private struct LUID
|
||||||
{
|
{
|
||||||
public int luidLow;
|
public int luidLow;
|
||||||
public int luidHigh;
|
public int luidHigh;
|
||||||
}
|
}
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
|
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
|
||||||
public class SSCS_EXT_T
|
public class SSCS_EXT_T
|
||||||
{
|
{
|
||||||
public int extID = 0; // defined to identify the extension
|
public int extID = 0; // defined to identify the extension
|
||||||
public int version = 0; // defined as the version of the specified extension
|
public int version = 0; // defined as the version of the specified extension
|
||||||
public IntPtr ext; // points to the actual extension
|
public IntPtr ext; // points to the actual extension
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
[DllImport(AUTH_LIBRARY, CharSet=CharSet.None) ]
|
[DllImport(AUTH_LIBRARY, CharSet=CharSet.None) ]
|
||||||
private static extern int ObtainAuthToken
|
private static extern int ObtainAuthToken
|
||||||
(
|
(
|
||||||
[In] byte[] baService,
|
[In] byte[] baService,
|
||||||
[In] byte[] baHost,
|
[In] byte[] baHost,
|
||||||
[In, Out] byte[] baToken,
|
[In, Out] byte[] baToken,
|
||||||
[In, Out] ref int iTokenLength
|
[In, Out] ref int iTokenLength
|
||||||
);
|
);
|
||||||
|
|
||||||
[DllImport(AUTH_LIBRARY, CharSet=CharSet.None) ]
|
[DllImport(AUTH_LIBRARY, CharSet=CharSet.None) ]
|
||||||
private static extern int ObtainAuthTokenEx
|
private static extern int ObtainAuthTokenEx
|
||||||
(
|
(
|
||||||
[In] byte[] baService,
|
[In] byte[] baService,
|
||||||
[In] byte[] baHost,
|
[In] byte[] baHost,
|
||||||
[In, Out] byte[] baToken,
|
[In, Out] byte[] baToken,
|
||||||
[In, Out] ref int iTokenLength,
|
[In, Out] ref int iTokenLength,
|
||||||
[In] SSCS_EXT_T ext
|
[In] SSCS_EXT_T ext
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
public Authtoken()
|
public Authtoken()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string ObtainAuthTokenAsString(string sService, string sHost)
|
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)
|
public static byte[] ObtainAuthToken(string sService, string sHost)
|
||||||
{
|
{
|
||||||
return ObtainAuthToken(sService, sHost, null);
|
return ObtainAuthToken(sService, sHost, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static byte[] ObtainAuthToken(string sService, string sHost, WinLuid luid)
|
private 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;
|
bool bLuidPassedIn = false;
|
||||||
|
|
||||||
byte[] baToken = new byte[bufferSize];
|
byte[] baToken = new byte[bufferSize];
|
||||||
|
|
||||||
// convert service to ascii byte array
|
// convert service to ascii byte array
|
||||||
if (sService != null)
|
if (sService != null)
|
||||||
{
|
{
|
||||||
baService = Encoding.ASCII.GetBytes(sService);
|
baService = Encoding.ASCII.GetBytes(sService);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
throw new Exception("Invalid parameter");
|
throw new Exception("Invalid parameter");
|
||||||
}
|
}
|
||||||
|
|
||||||
// convert host to ascii byte array
|
// convert host to ascii byte array
|
||||||
if (sHost != null)
|
if (sHost != null)
|
||||||
{
|
{
|
||||||
baHost = Encoding.ASCII.GetBytes(sHost);
|
baHost = Encoding.ASCII.GetBytes(sHost);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
throw new Exception("Invalid parameter");
|
throw new Exception("Invalid parameter");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
SSCS_EXT_T ext = new SSCS_EXT_T();
|
SSCS_EXT_T ext = new SSCS_EXT_T();
|
||||||
if ((luid != null) && (luid.GetHighPart() != 0) || (luid.GetLowPart() != 0))
|
LUID sluid;
|
||||||
{
|
if ((luid != null) && (luid.GetHighPart() != 0) || (luid.GetLowPart() != 0))
|
||||||
// allocate a structure to marshal
|
{
|
||||||
LUID sluid = new LUID();
|
// allocate a structure to marshal
|
||||||
sluid.luidHigh = luid.GetHighPart();
|
sluid = new LUID();
|
||||||
sluid.luidLow = luid.GetLowPart();
|
sluid.luidHigh = luid.GetHighPart();
|
||||||
|
sluid.luidLow = luid.GetLowPart();
|
||||||
ext.extID = 1;
|
|
||||||
ext.version = 1;
|
ext.extID = 1;
|
||||||
ext.ext = Marshal.AllocHGlobal(Marshal.SizeOf(sluid));
|
ext.version = 1;
|
||||||
|
ext.ext = Marshal.AllocHGlobal(Marshal.SizeOf(sluid));
|
||||||
|
|
||||||
Marshal.StructureToPtr(sluid, ext.ext, false);
|
Marshal.StructureToPtr(sluid, ext.ext, false);
|
||||||
bLuidPassedIn = true;
|
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
|
||||||
{
|
{
|
||||||
if (bLuidPassedIn)
|
if (bLuidPassedIn)
|
||||||
{
|
{
|
||||||
rcode = ObtainAuthTokenEx(baService, baHost, baToken, ref bufferSize, ext);
|
rcode = ObtainAuthTokenEx(baService, baHost, baToken, ref bufferSize, ext);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
rcode = ObtainAuthToken(baService, baHost, baToken, ref bufferSize);
|
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)
|
||||||
{
|
{
|
||||||
// now allocate the proper size
|
// now allocate the proper size
|
||||||
baToken = new byte[bufferSize];
|
baToken = new byte[bufferSize];
|
||||||
if (bLuidPassedIn)
|
if (bLuidPassedIn)
|
||||||
{
|
{
|
||||||
rcode = ObtainAuthTokenEx(baService, baHost, baToken, ref bufferSize, ext);
|
rcode = ObtainAuthTokenEx(baService, baHost, baToken, ref bufferSize, ext);
|
||||||
@ -167,30 +168,30 @@ namespace Novell.Casa.Client.Auth
|
|||||||
{
|
{
|
||||||
rcode = ObtainAuthToken(baService, baHost, baToken, ref bufferSize);
|
rcode = ObtainAuthToken(baService, baHost, baToken, ref bufferSize);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
LogMessage(e.ToString());
|
LogMessage(e.ToString());
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ext.ext != IntPtr.Zero)
|
if (ext.ext != IntPtr.Zero)
|
||||||
Marshal.FreeHGlobal(ext.ext);
|
Marshal.FreeHGlobal(ext.ext);
|
||||||
|
|
||||||
if (rcode != 0)
|
if (rcode != 0)
|
||||||
{
|
{
|
||||||
throw new Exception(rcode.ToString());
|
throw new Exception(rcode.ToString());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return baToken;
|
return baToken;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void LogMessage(string sMessage)
|
private static void LogMessage(string sMessage)
|
||||||
{
|
{
|
||||||
System.Diagnostics.Trace.WriteLine("(C#)AuthToken: " + sMessage);
|
System.Diagnostics.Trace.WriteLine("(C#)AuthToken: " + sMessage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
Version="8.00"
|
Version="8.00"
|
||||||
Name="test"
|
Name="test"
|
||||||
ProjectGUID="{6034EBF1-0838-45C4-A538-A41A31EC8F46}"
|
ProjectGUID="{6034EBF1-0838-45C4-A538-A41A31EC8F46}"
|
||||||
|
RootNamespace="test"
|
||||||
Keyword="Win32Proj"
|
Keyword="Win32Proj"
|
||||||
>
|
>
|
||||||
<Platforms>
|
<Platforms>
|
||||||
@ -62,10 +63,10 @@
|
|||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCLinkerTool"
|
Name="VCLinkerTool"
|
||||||
AdditionalDependencies="authtoken.lib ws2_32.lib"
|
AdditionalDependencies="casa_authtoken.lib ws2_32.lib"
|
||||||
OutputFile="$(OutDir)/test.exe"
|
OutputFile="$(OutDir)/test.exe"
|
||||||
LinkIncremental="2"
|
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"
|
GenerateDebugInformation="true"
|
||||||
ProgramDatabaseFile="$(OutDir)/test.pdb"
|
ProgramDatabaseFile="$(OutDir)/test.pdb"
|
||||||
SubSystem="1"
|
SubSystem="1"
|
||||||
@ -94,7 +95,7 @@
|
|||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCPostBuildEventTool"
|
Name="VCPostBuildEventTool"
|
||||||
CommandLine="copy ..\..\windows\debug\authtoken.dll debug\authtoken.dll"
|
CommandLine="copy ..\..\windows\debug\casa_authtoken.dll debug\casa_authtoken.dll"
|
||||||
/>
|
/>
|
||||||
</Configuration>
|
</Configuration>
|
||||||
<Configuration
|
<Configuration
|
||||||
@ -142,7 +143,7 @@
|
|||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCLinkerTool"
|
Name="VCLinkerTool"
|
||||||
AdditionalDependencies="authtoken.lib ws2_32.lib"
|
AdditionalDependencies="casa_authtoken.lib ws2_32.lib"
|
||||||
OutputFile="$(OutDir)/test.exe"
|
OutputFile="$(OutDir)/test.exe"
|
||||||
LinkIncremental="1"
|
LinkIncremental="1"
|
||||||
AdditionalLibraryDirectories=""C:\Program Files\novell\CASA\lib""
|
AdditionalLibraryDirectories=""C:\Program Files\novell\CASA\lib""
|
||||||
|
@ -67,7 +67,7 @@
|
|||||||
IgnoreImportLibrary="false"
|
IgnoreImportLibrary="false"
|
||||||
AdditionalOptions="/EXPORT:ObtainAuthToken /EXPORT:ObtainAuthTokenEx"
|
AdditionalOptions="/EXPORT:ObtainAuthToken /EXPORT:ObtainAuthTokenEx"
|
||||||
AdditionalDependencies="ws2_32.lib winhttp.lib libexpatml.lib micasa.lib shlwapi.lib"
|
AdditionalDependencies="ws2_32.lib winhttp.lib libexpatml.lib micasa.lib shlwapi.lib"
|
||||||
OutputFile="$(OutDir)/authtoken.dll"
|
OutputFile="$(OutDir)/casa_authtoken.dll"
|
||||||
LinkIncremental="1"
|
LinkIncremental="1"
|
||||||
AdditionalLibraryDirectories=""\Program Files\Microsoft Platform SDK\lib";"\Program Files\Novell\CASA\lib";"C:\Dev\Expat-2.0.0\StaticLibs""
|
AdditionalLibraryDirectories=""\Program Files\Microsoft Platform SDK\lib";"\Program Files\Novell\CASA\lib";"C:\Dev\Expat-2.0.0\StaticLibs""
|
||||||
IgnoreAllDefaultLibraries="false"
|
IgnoreAllDefaultLibraries="false"
|
||||||
@ -151,7 +151,7 @@
|
|||||||
Name="VCLinkerTool"
|
Name="VCLinkerTool"
|
||||||
AdditionalOptions="/EXPORT:ObtainAuthToken /EXPORT:ObtainAuthTokenEx"
|
AdditionalOptions="/EXPORT:ObtainAuthToken /EXPORT:ObtainAuthTokenEx"
|
||||||
AdditionalDependencies="ws2_32.lib winhttp.lib libexpatml.lib micasa.lib shlwapi.lib"
|
AdditionalDependencies="ws2_32.lib winhttp.lib libexpatml.lib micasa.lib shlwapi.lib"
|
||||||
OutputFile="$(OutDir)/authtoken.dll"
|
OutputFile="$(OutDir)/casa_authtoken.dll"
|
||||||
LinkIncremental="1"
|
LinkIncremental="1"
|
||||||
AdditionalLibraryDirectories=""\Program Files\Microsoft Platform SDK\lib";"\Program Files\Novell\CASA\lib";"C:\Dev\Expat-2.0.0\StaticLibs""
|
AdditionalLibraryDirectories=""\Program Files\Microsoft Platform SDK\lib";"\Program Files\Novell\CASA\lib";"C:\Dev\Expat-2.0.0\StaticLibs""
|
||||||
IgnoreDefaultLibraryNames="libc"
|
IgnoreDefaultLibraryNames="libc"
|
||||||
|
@ -34,13 +34,19 @@
|
|||||||
"Entry"
|
"Entry"
|
||||||
{
|
{
|
||||||
"MsmKey" = "8:_71C343EBC4935F8914C3145115EDEC4A"
|
"MsmKey" = "8:_71C343EBC4935F8914C3145115EDEC4A"
|
||||||
"OwnerKey" = "8:_C1C37E2154994C29B02FDD9C90635B26"
|
"OwnerKey" = "8:_8E623C85FD4143F3B09460457E8ED6CA"
|
||||||
"MsmSig" = "8:_UNDEFINED"
|
"MsmSig" = "8:_UNDEFINED"
|
||||||
}
|
}
|
||||||
"Entry"
|
"Entry"
|
||||||
{
|
{
|
||||||
"MsmKey" = "8:_71C343EBC4935F8914C3145115EDEC4A"
|
"MsmKey" = "8:_71C343EBC4935F8914C3145115EDEC4A"
|
||||||
"OwnerKey" = "8:_8E623C85FD4143F3B09460457E8ED6CA"
|
"OwnerKey" = "8:_C1C37E2154994C29B02FDD9C90635B26"
|
||||||
|
"MsmSig" = "8:_UNDEFINED"
|
||||||
|
}
|
||||||
|
"Entry"
|
||||||
|
{
|
||||||
|
"MsmKey" = "8:_75519C9025D94CC496F276E698CE3AF8"
|
||||||
|
"OwnerKey" = "8:_UNDEFINED"
|
||||||
"MsmSig" = "8:_UNDEFINED"
|
"MsmSig" = "8:_UNDEFINED"
|
||||||
}
|
}
|
||||||
"Entry"
|
"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"
|
"{5259A561-127C-4D43-A0A1-72F10C7B3BF8}:_8E623C85FD4143F3B09460457E8ED6CA"
|
||||||
{
|
{
|
||||||
"SourcePath" = "8:..\\..\\..\\lib\\mechanisms\\pwd\\windows\\Debug\\pwmech.dll"
|
"SourcePath" = "8:..\\..\\..\\lib\\mechanisms\\pwd\\windows\\Debug\\pwmech.dll"
|
||||||
@ -517,7 +551,7 @@
|
|||||||
}
|
}
|
||||||
"{5259A561-127C-4D43-A0A1-72F10C7B3BF8}:_C1C37E2154994C29B02FDD9C90635B26"
|
"{5259A561-127C-4D43-A0A1-72F10C7B3BF8}:_C1C37E2154994C29B02FDD9C90635B26"
|
||||||
{
|
{
|
||||||
"SourcePath" = "8:..\\..\\..\\lib\\windows\\Debug\\authtoken.dll"
|
"SourcePath" = "8:..\\..\\..\\lib\\windows\\Debug\\casa_authtoken.dll"
|
||||||
"TargetName" = "8:"
|
"TargetName" = "8:"
|
||||||
"Tag" = "8:"
|
"Tag" = "8:"
|
||||||
"Folder" = "8:_01897726E7804A3B875B67A1C2692147"
|
"Folder" = "8:_01897726E7804A3B875B67A1C2692147"
|
||||||
|
Loading…
Reference in New Issue
Block a user