Exemplo n.º 1
0
        public static string MetricsToString_0(LsaMetricPack_0 metrics)
        {
            string[] parts = new string[] {
                "\nfailedAuthentications: ",
                metrics.failedAuthentications.ToString(),
                "\nfailedUserLookupsByName:  ",
                metrics.failedUserLookupsByName.ToString(),
                "\nfailedUserLookupsById:  ",
                metrics.failedUserLookupsById.ToString(),
                "\nfailedGroupLookupsByName:  ",
                metrics.failedGroupLookupsByName.ToString(),
                "\nfailedGroupLookupsById:  ",
                metrics.failedGroupLookupsById.ToString(),
                "\nfailedOpenSession:  ",
                metrics.failedOpenSession.ToString(),
                "\nfailedCloseSession:  ",
                metrics.failedCloseSession.ToString(),
                "\nfailedChangePassword:  "******"\nunauthorizedAccesses:  ",
                metrics.unauthorizedAccesses.ToString(),
                "\n"
            };

            string result = String.Concat(parts);

            return(result);
        }
Exemplo n.º 2
0
        public static UInt32 LSAMgmtQueryLsaMetrics_0(string serverName, out LsaMetricPack_0 metrics)
        {
            UInt32 result       = 0;
            string functionName = "LSAMgmtAPI.LSAMgmtQueryLsaMetrics_0";
            IntPtr pMetrics     = IntPtr.Zero;

            metrics = new LsaMetricPack_0();

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

                result = PrivateLSAMgmtAPI.LWMGMTQueryLsaMetrics_0(
                    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_0)Marshal.PtrToStructure(pMetrics, typeof(LsaMetricPack_0));

                Logger.Log(String.Format(
                               "{0}: result={1} metrics:\n{2}",
                               functionName,
                               result,
                               MetricsToString_0(metrics)),
                           Logger.LSAMgmtLogLevel);

                int freeSuccess = (int)PrivateLSAMgmtAPI.LWMGMTFreeLsaMetrics_0(pMetrics);
                if (freeSuccess != 0)
                {
                    Logger.Log(String.Format(
                                   "WARNING: PrivateLSAMgmtAPI.LWMGMTFreeLsaMetrics_0 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 string MetricsToString_0(LsaMetricPack_0 metrics)
        {
            string[] parts = new string[] {
                "\nfailedAuthentications: ",
                metrics.failedAuthentications.ToString(),
                "\nfailedUserLookupsByName:  ",
                metrics.failedUserLookupsByName.ToString(),
                "\nfailedUserLookupsById:  ",
                metrics.failedUserLookupsById.ToString(),
                "\nfailedGroupLookupsByName:  ",
                metrics.failedGroupLookupsByName.ToString(),
                "\nfailedGroupLookupsById:  ",
                metrics.failedGroupLookupsById.ToString(),
                "\nfailedOpenSession:  ",
                metrics.failedOpenSession.ToString(),
                "\nfailedCloseSession:  ",
                metrics.failedCloseSession.ToString(),
                "\nfailedChangePassword:  "******"\nunauthorizedAccesses:  ",
                metrics.unauthorizedAccesses.ToString(),
                "\n"
            };

            string result = String.Concat(parts);
            return result;
        }
Exemplo n.º 4
0
        public static UInt32 LSAMgmtQueryLsaMetrics_0(string serverName, out LsaMetricPack_0 metrics)
        {
            UInt32 result = 0;
            string functionName = "LSAMgmtAPI.LSAMgmtQueryLsaMetrics_0";
            IntPtr pMetrics = IntPtr.Zero;
            metrics = new LsaMetricPack_0();

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

                result = PrivateLSAMgmtAPI.LWMGMTQueryLsaMetrics_0(
                    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_0)Marshal.PtrToStructure(pMetrics, typeof(LsaMetricPack_0));

                Logger.Log(String.Format(
                        "{0}: result={1} metrics:\n{2}",
                        functionName,
                        result,
                        MetricsToString_0(metrics)),
                        Logger.LSAMgmtLogLevel);

                int freeSuccess = (int)PrivateLSAMgmtAPI.LWMGMTFreeLsaMetrics_0(pMetrics);
                if (freeSuccess != 0)
                {
                    Logger.Log(String.Format(
                        "WARNING: PrivateLSAMgmtAPI.LWMGMTFreeLsaMetrics_0 reports failure! [code={0}]",
                        freeSuccess),
                        Logger.LogLevel.Panic);
                }

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

        }