But ...
$ldap="LDAP://"+@domain+"/"+GetObject("LDAP://rootDSE").Get("defaultNamingContext")
is a combination of LDAP and macros.
I wonderd if there was a LDAP question from ActiveDirectory that give me the same answer as @Domain.
Maybe for example GetObject("LDAP://rootDSE").Get("NetBiosDomainName").

/Mima