Jump to content

Recommended Posts

Posted

Hello,

I would like to get the NETBIOS Domain of the computer the script is running on.

There´s no problem to get the Domain of the logged on user, but the computer

domain might be different.

Does anyone got an suggestion, how to get this value?

Thanx in advance for any suggestions!

Jochen

Posted

@Zedna: WMI wolud retrieve the FQDN AFAIK

@PerryRaptor: I would like to retrieve the NetBIOS Domain name of my computer and not only the name of my computer

Thanx in advance

Jochen

Posted

Try this UDF:

Func _GetNetBIOSDomain()
    local $objRootDSE = ObjGet("LDAP://RootDSE")
    local $strDNSDomain = $objRootDSE.Get("defaultNamingContext")
    local $objTrans = ObjCreate("NameTranslate")
    $objTrans.Init(3, "") ; 3 = ADS_NAME_INITTYPE_GC
    $objTrans.Set(1, $strDNSDomain) ; 1=ADS_NAME_TYPE_1779
    local $strNetBIOSDomain = $objTrans.Get(3) ; 3=ADS_NAME_TYPE_NT4
    return StringLeft($strNetBIOSDomain, StringLen($strNetBIOSDomain) - 1)
EndFunc

ConsoleWrite("NetBIOS Domain Name: " & _GetNetBIOSDomain() & @CRLF)

[font="Fixedsys"][list][*]All of my AutoIt Example Scripts[*]http://saneasylum.com[/list][/font]

Posted

Hallo lod3n,

now I can test it only in a single domain environment.

I posted that i would like to retrieve the computer domain name and not the userdomain.

Does your script does this?

If i would like to retrieve the userdomain, i can have a look the the registry.

Thanks in advance

Jochen

Posted

Ah, sorry about that. What you are asking for (now I understand) is exceedingly easy:

$objWinNTSysInfo = ObjCreate("WinNTSystemInfo")
ConsoleWrite($objWinNTSysInfo.DomainName & @crlf)

This will work on Windows 2000 or above, or NT with DSClient installed:

http://support.microsoft.com/kb/288358

According to that article, possibly also Win98, but I'm not sure, and can't test that.

[font="Fixedsys"][list][*]All of my AutoIt Example Scripts[*]http://saneasylum.com[/list][/font]

  • 5 years later...
Posted

Sorry for dragging up such an old thread, but that didn't work for me. When running as a user other than the logged in user, the above still returns the user domain, not the Computer domain. Here's some very simple AutoIt code which will return the Computer domain;

$objSystemInfo = ObjCreate("ADSystemInfo")
$domain = $objSystemInfo.DomainShortName
MsgBox(0, "Domain", $domain)

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...