Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8973399
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T18:26:13+00:00 2026-06-15T18:26:13+00:00

We have a domain with full name, e.g. long-domainname.com ; this domain name is

  • 0

We have a domain with full name, e.g. long-domainname.com; this domain name is replaced with alias short. this alias can be retrieved using netapi32.dll, like this:

[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 &&
            status == NetJoinStatus.NetSetupDomainName)
        {
            domain = Marshal.PtrToStringAuto(pDomain);
        }
    }
    finally
    {
        if (pDomain != IntPtr.Zero) NetApiBufferFree(pDomain);
    }
    if (domain == null) domain = "";
    return domain;
}

This method return the sort value. But using the System.DirectoryServices.ActiveDirectory.Domain class, and its Name property, I get long-domainname.com value. Searching the properties under the Debug mode, I couldn’t find any short value field or property. Is it possible with System.DirectoryServices.ActiveDirectory.Domain class? Or may be it is possible with some other class of System.DirectoryServices namespace? How to get the short domain name value without importing external *.dll?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T18:26:15+00:00Added an answer on June 15, 2026 at 6:26 pm
    private string GetNetbiosDomainName(string dnsDomainName)
        {
            string netbiosDomainName = string.Empty;
    
            DirectoryEntry rootDSE = new DirectoryEntry("LDAP://RootDSE");
    
            string configurationNamingContext = rootDSE.Properties["configurationNamingContext"][0].ToString();
    
            DirectoryEntry searchRoot = new DirectoryEntry("LDAP://cn=Partitions," + configurationNamingContext);
    
            DirectorySearcher searcher = new DirectorySearcher(searchRoot);
            searcher.SearchScope = SearchScope.OneLevel;
            searcher.PropertiesToLoad.Add("netbiosname");
            searcher.Filter = string.Format("(&(objectcategory=Crossref)(dnsRoot={0})(netBIOSName=*))", dnsDomainName);
    
            SearchResult result = searcher.FindOne();
    
            if (result != null)
            {
                netbiosDomainName = result.Properties["netbiosname"][0].ToString();
            }
    
            return netbiosDomainName;
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have a domain full-ops.com that i transferred to another host, but it takes
If I have domain name example.com , and if I set an A record
When I try to post this email : name+1@domain.com I get name 1@domain.com in
I have domain classes => many-to-many and associate them using addTo. class Books {
I have domain site.com and there is subdomain sub.site.com Once you open sub.site.com you
I have a domain with wildcard - *.mysite.com hosted on Server1 I am planning
I have a domain name and my rails application. Is there any way to
I have a domain class: class Author { String name static hasMany = [superFantasticAndAwesomeBooks:
I have a domain with host www.mydomainhost.com . Now i got another domain named
I have been trying to user sharepoint designer to retrieve the user's full name

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.