Forum Discussion

fazlook's avatar
fazlook
Frequent Contributor
9 years ago

How do I get the domain type using TC ?

Let's say my domain is TC.com or TC.ca, how do I get the ca or com part ?

 

SYS.domainname gives me only the name.

 

Thank you

 


  • cunderw wrote:

    It sounds like you want the the domain name of your computer? SYS.domainname is for the currently loggen in user which isn't always the name of the domain. You wnat the system domain name.

     

    Try this:

     

    dotNET.System_DirectoryServices_ActiveDirectory.Domain.GetComputerDomain().ToString();

     

    You will have to add the System.DirectoryServices component to your CLR bridge to access this.


    Here's another way, without using .NET:

    ' VBScript
    CreateObject("ADSystemInfo").DomainDNSName
    
    // JScript
    (new ActiveXObject("ADSystemInfo")).DomainDNSName
  • Sys.DomainName probably isn't what you are looking for, it give you the network domain that your PC belongs to. I'm guessing you want to grab the TLD of a website you have opened in a browser. There isn't a specific function in TC that will retrieve that for you, but it's not too hard to parse the URL. Here's an example in python:

     

     

    def get_TLD(url):
    #Split the url until it's only the hostname split into a list baseURL = url.split('//')[1].split('/')[0].split('.')
    #Return the last item in the list, which will be com or whatever else return baseURL[len(baseURL) - 1] def test(): #Sends the results to log
    url = str(Aliases.browser.Page('somePage').URL) Log.Message(get_TLD(url))

     

     

    Only problem is it doesn't completely work with TLDs that have two parts (e.g. co.uk). But if you are testing any websites with a possible two part TLD you can add some logic to the get_TLD function so that it returns the full co.uk if it first grabs .uk

  • cunderw's avatar
    cunderw
    Community Hero

    It sounds like you want the the domain name of your computer? SYS.domainname is for the currently loggen in user which isn't always the name of the domain. You wnat the system domain name.

     

    Try this:

     

    dotNET.System_DirectoryServices_ActiveDirectory.Domain.GetComputerDomain().ToString();

     

    You will have to add the System.DirectoryServices component to your CLR bridge to access this.

    • HKosova's avatar
      HKosova
      SmartBear Alumni (Retired)

      cunderw wrote:

      It sounds like you want the the domain name of your computer? SYS.domainname is for the currently loggen in user which isn't always the name of the domain. You wnat the system domain name.

       

      Try this:

       

      dotNET.System_DirectoryServices_ActiveDirectory.Domain.GetComputerDomain().ToString();

       

      You will have to add the System.DirectoryServices component to your CLR bridge to access this.


      Here's another way, without using .NET:

      ' VBScript
      CreateObject("ADSystemInfo").DomainDNSName
      
      // JScript
      (new ActiveXObject("ADSystemInfo")).DomainDNSName