Advertisement
kijato

Try Sentinel Admin API .NET Class Library Reference

May 12th, 2020
1,158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.15 KB | None | 0 0
  1. /*
  2. set PATH=c:\Windows\Microsoft.NET\Framework64\v4.0.30319;%PATH%
  3. cls && csc.exe -debug- -target:winexe -platform:x64 -r:sntl_adminapi_net_windows.dll sntl_adminapi_net_windows.cs && sntl_adminapi_net_windows.exe
  4. */
  5.  
  6. using System;
  7. //using System.Collections.Generic;
  8. //using System.Text;
  9. //using System.Text.RegularExpressions;
  10. using System.Runtime.InteropServices; // ez a névtér szükséges a DLL-ek miatt
  11. using System.Xml;
  12. using System.IO;
  13. using SafeNet.Sentinel;
  14.  
  15. public class WinAPI
  16. {
  17.     [DllImport("user32.dll")]
  18.     public static extern int MessageBox(int hWnd, string text, string caption, uint type);
  19. }
  20.  
  21. namespace TrySentinelLDK
  22. {
  23.     class TrySentinelLDK
  24.     {
  25.        
  26.         private static AdminApi adminApi;
  27.         private static int vendorId = 00000;
  28.        
  29.         static void Main(string[] args)
  30.         {
  31.             string scope = "";
  32.             string format = "";
  33.             string info = "";
  34.            
  35.             adminApi = new AdminApi("localhost", 1947, "");
  36.             AdminStatus rc = default(AdminStatus);
  37.  
  38.             try
  39.             {
  40.                 rc = adminApi.connect();
  41.                 //WinAPI.MessageBox(0, "["+rc.ToString()+"]", "MessageBox...", 0);
  42.                
  43.                 scope = "<haspscope>" +
  44.                         " <vendor id=\"" + vendorId + "\" />" +
  45.                         "</haspscope>";
  46.                        
  47.                 format = "<admin> <hasp>" +
  48.                         //"  <element name=\"*\" />" +
  49.                         "  <element name=\"haspid\" />" +
  50.                         "</hasp></admin>";
  51.                
  52.                 rc = adminApi.adminGet( scope, format, ref info );
  53.                 //Console.WriteLine(info);
  54.                 //WinAPI.MessageBox(0, "["+rc.ToString()+"]" + Convert.ToChar(10)+ Convert.ToChar(10) + info, "MessageBox...", 0);
  55.                
  56.                 XmlReader reader = XmlReader.Create(new StringReader(info));
  57.                 while (reader.Read())
  58.                 {
  59.                     if (reader.NodeType==XmlNodeType.Element && reader.Name == "haspid")
  60.                     {
  61.                         if (reader.Read())
  62.                         //Console.WriteLine("___"+reader.Value+"___");
  63.                         WinAPI.MessageBox(0, reader.Value, "Kulcs sorszám...", 0);
  64.                         break;
  65.                     }
  66.                 }
  67.             }
  68.             catch (Exception e)
  69.             {
  70.                 Console.WriteLine(e.Message);
  71.             }
  72.            
  73.             //Console.WriteLine("Press any key to exit.");
  74.             //Console.ReadKey();
  75.         }
  76.     }
  77. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement