Exemplo n.º 1
0
        public static UInt32 LWMGMTReadKeyTab(string serverName,
                                              string KeyTabPath,
                                              UInt32 LastRecordId,
                                              UInt32 RecordsPerPage,
                                              out IntPtr pKeyTabEntries)
        {
            UInt32 result       = 0;
            string functionName = "LSAMgmtAPI.LWMGMTReadKeyTab";

            IntPtr kaytab_entries = IntPtr.Zero;

            try
            {
                Logger.Log(String.Format(
                               "{0}(serverName={1}) called",
                               functionName, serverName), Logger.LSAMgmtLogLevel);

                result = PrivateLSAMgmtAPI.LWMGMTReadKeyTab(
                    serverName,
                    KeyTabPath,
                    LastRecordId,
                    RecordsPerPage,
                    out kaytab_entries);

                if (result != 0)
                {
                    pKeyTabEntries = IntPtr.Zero;
                    return(result);
                }

                if (kaytab_entries.Equals(IntPtr.Zero))
                {
                    throw new Exception("Failed to read kay tab entry information; null handle returned");
                }

                Logger.Log(String.Format(
                               "LWMGMTReadKeyTab returns non zero value for kaytab_entries {0}", kaytab_entries),
                           Logger.LSAMgmtLogLevel);

                Logger.Log(String.Format(
                               "{0}: result={1}",
                               functionName,
                               result),
                           Logger.LSAMgmtLogLevel);

                pKeyTabEntries = kaytab_entries;
            }
            catch (Exception ex)
            {
                Logger.LogException(functionName, ex);
                if (result == 0)
                {
                    result = 0xFFFFFFFF;
                }

                pKeyTabEntries = IntPtr.Zero;
            }

            return(result);
        }
Exemplo n.º 2
0
        public static UInt32 LSAMgmtQueryLsaMetrics_1(string serverName, out LsaMetricPack_1 metrics)
        {
            UInt32 result       = 0;
            string functionName = "LSAMgmtAPI.LSAMgmtQueryLsaMetrics_1";

            IntPtr pMetrics = IntPtr.Zero;

            metrics = new LsaMetricPack_1();

            try
            {
                Logger.Log(String.Format(
                               "{0}(serverName={1}) called",
                               functionName, serverName), Logger.LSAMgmtLogLevel);

                result = PrivateLSAMgmtAPI.LWMGMTQueryLsaMetrics_1(
                    serverName, out pMetrics);

                if (result != 0)
                {
                    return(result);
                }

                if (pMetrics.Equals(IntPtr.Zero))
                {
                    throw new Exception("Failed to read metrics; null handle returned");
                }

                metrics = (LsaMetricPack_1)Marshal.PtrToStructure(pMetrics, typeof(LsaMetricPack_1));

                Logger.Log(String.Format(
                               "{0}: result={1}",
                               functionName,
                               result),
                           Logger.LSAMgmtLogLevel);


                int freeSuccess = (int)PrivateLSAMgmtAPI.LWMGMTFreeLsaMetrics_1(pMetrics);
                if (freeSuccess != 0)
                {
                    Logger.Log(String.Format(
                                   "WARNING: PrivateLSAMgmtAPI.LWMGMTFreeLsaMetrics_1 reports failure! [code={0}]",
                                   freeSuccess),
                               Logger.LogLevel.Panic);
                }
            }
            catch (Exception ex)
            {
                Logger.LogException(functionName, ex);
                if (result == 0)
                {
                    result = 0xFFFFFFFF;
                }
            }
            return(result);
        }
Exemplo n.º 3
0
        public static UInt32 LWMGMTQueryLsaStatus(string serverName, out IntPtr pLsaStatus)
        {
            UInt32 result       = 0;
            string functionName = "LSAMgmtAPI.LWMGMTQueryLsaStatus";

            IntPtr lsa_status = IntPtr.Zero;

            try
            {
                Logger.Log(String.Format(
                               "{0}(serverName={1}) called",
                               functionName, serverName), Logger.LSAMgmtLogLevel);

                result = PrivateLSAMgmtAPI.LWMGMTQueryLsaStatus(
                    serverName,
                    out lsa_status);

                if (result != 0)
                {
                    pLsaStatus = IntPtr.Zero;
                    return(result);
                }

                if (lsa_status.Equals(IntPtr.Zero))
                {
                    throw new Exception("Failed to read status information; null handle returned");
                }

                Logger.Log(String.Format(
                               "LWMGMTQueryLsaStatus returns non zero value for pLsaStatus {0}", lsa_status),
                           Logger.LSAMgmtLogLevel);

                Logger.Log(String.Format(
                               "{0}: result={1}",
                               functionName,
                               result),
                           Logger.LSAMgmtLogLevel);

                pLsaStatus = lsa_status;
            }
            catch (Exception ex)
            {
                Logger.LogException(functionName, ex);
                if (result == 0)
                {
                    result = 0xFFFFFFFF;
                }

                pLsaStatus = IntPtr.Zero;
            }

            return(result);
        }
Exemplo n.º 4
0
        public static UInt32 LWMGMTCountKeyTabEntries(string serverName, string keyTabPath, out UInt32 pdwCount)
        {
            UInt32 result       = 0;
            string functionName = "LSAMgmtAPI.LWMGMTCountKeyTabEntries";
            UInt32 count        = 0;

            try
            {
                Logger.Log(String.Format(
                               "{0}(serverName={1}) called",
                               functionName, serverName), Logger.LSAMgmtLogLevel);

                result = PrivateLSAMgmtAPI.LWMGMTCountKeyTabEntries(
                    serverName,
                    keyTabPath,
                    out count);

                if (result != 0)
                {
                    pdwCount = 0;
                    return(result);
                }

                Logger.Log(String.Format(
                               "LWMGMTCountKeyTabEntries returns non zero value for pdwCount {0}", count),
                           Logger.LSAMgmtLogLevel);

                Logger.Log(String.Format(
                               "{0}: result={1}",
                               functionName,
                               result),
                           Logger.LSAMgmtLogLevel);

                pdwCount = count;
            }
            catch (Exception ex)
            {
                Logger.LogException(functionName, ex);
                if (result == 0)
                {
                    result = 0xFFFFFFFF;
                }

                pdwCount = 0;
            }

            return(result);
        }
Exemplo n.º 5
0
        public static UInt32 LWMGMTFreeKeyTabEntries(IntPtr pKeyTabEntries)
        {
            UInt32 result       = 0;
            string functionName = "LSAMgmtAPI.LWMGMTFreeKeyTabEntries";

            try
            {
                Logger.Log(String.Format(
                               "{0} called",
                               functionName), Logger.LSAMgmtLogLevel);

                if (!IntPtr.Zero.Equals(pKeyTabEntries))
                {
                    result = PrivateLSAMgmtAPI.LWMGMTFreeKeyTabEntries(pKeyTabEntries);
                    if (result != 0)
                    {
                        Logger.Log(String.Format(
                                       "WARNING: PrivateLSAMgmtAPI.LWMGMTFreeKeyTabEntries reports failure! [code={0}]",
                                       result),
                                   Logger.LogLevel.Panic);
                    }
                }

                Logger.Log(String.Format(
                               "{0}: result={1}",
                               functionName,
                               result),
                           Logger.LSAMgmtLogLevel);
            }
            catch (Exception ex)
            {
                Logger.LogException(functionName, ex);
                if (result == 0)
                {
                    result = 0xFFFFFFFF;
                }
            }

            return(result);
        }