Ejemplo n.º 1
0
        internal static string GetDCName()
        {
            // retrieves the current domain controller name
            // adapted from https://www.pinvoke.net/default.aspx/netapi32.dsgetdcname
            Interop.DOMAIN_CONTROLLER_INFO domainInfo;
            IntPtr pDCI = IntPtr.Zero;

            try {
                NativeReturnCode val = Interop.DsGetDcName("", "", 0, "",
                                                           Interop.DSGETDCNAME_FLAGS.DS_DIRECTORY_SERVICE_REQUIRED |
                                                           Interop.DSGETDCNAME_FLAGS.DS_RETURN_DNS_NAME |
                                                           Interop.DSGETDCNAME_FLAGS.DS_IP_REQUIRED, out pDCI);
                if (NativeReturnCode.ERROR_SUCCESS == val)
                {
                    domainInfo = (Interop.DOMAIN_CONTROLLER_INFO)Marshal.PtrToStructure(pDCI, typeof(Interop.DOMAIN_CONTROLLER_INFO));
                    return(domainInfo.DomainControllerName.Trim('\\'));
                }
                Console.WriteLine("\r\n  [X] Error {0} retrieving domain controller : {1}", val,
                                  new Win32Exception((int)val).Message);
                return(string.Empty);
            }
            finally {
                if (IntPtr.Zero != pDCI)
                {
                    Interop.NetApiBufferFree(pDCI);
                }
            }
        }
Ejemplo n.º 2
0
 internal LSAException(NativeReturnCode lsaRetCode, string message, Exception innerException)
     : base(message, innerException)
 {
     LSARetCode = lsaRetCode;
 }
Ejemplo n.º 3
0
 internal LSAException(NativeReturnCode lsaRetCode)
 {
     LSARetCode = lsaRetCode;
 }
Ejemplo n.º 4
0
 internal static void ValidateNativeCall(NativeReturnCode code)
 {
 }