title: How to get domain alias using System.DirectoryServices.ActiveDirectory.Domain class
body: <p>We have a domain with full name, e.g. <strong>long-domainname.com</strong>; this domain name is replaced with alias <strong>short</strong>. this alias can be retrieved using <code>netapi32.dll</code>, like this:</p>
  
  <pre><code>[DllImport("Netapi32.dll")]
  static extern int NetApiBufferFree(IntPtr Buffer);
  
  // Returns the domain name the computer is joined to, or "" if not joined.
  public static string GetJoinedDomain()
  {
      int result = 0;
      string domain = null;
      IntPtr pDomain = IntPtr.Zero;
      NetJoinStatus status = NetJoinStatus.NetSetupUnknownStatus;
      try
      {
          result = NetGetJoinInformation(null, out pDomain, out status);
          if (result == ErrorSuccess &amp;&amp;
              status == NetJoinStatus.NetSetupDomainName)
          {
              domain = Marshal.PtrToStringAuto(pDomain);
          }
      }
      finally
      {
          if (pDomain != IntPtr.Zero) NetApiBufferFree(pDomain);
      }
      if (domain == null) domain = "";
      return domain;
  }
  </code></pre>
  
  <p>This method return the <strong>sort</strong> value. But using the <code>System.DirectoryServices.ActiveDirectory.Domain</code> class, and its <code>Name</code> property, I get <strong>long-domainname.com</strong> value. Searching the properties under the Debug mode, I couldn't find any <strong>short</strong> value field or property. Is it possible with <code>System.DirectoryServices.ActiveDirectory.Domain</code> class? Or may be it is possible with some other class of <code>System.DirectoryServices</code> namespace? How to get the <strong>short</strong> domain name value without importing external *.dll?</p>