How to Get Domain Information using Javascripting

Joined
Feb 19, 2014
Messages
5
Reaction score
0
Points
1
HI all,

How do I fetch my MAC "Domain" information programatically using javascripting.

I Tried using the below code to get the user information.

alert($.getenv("USER"))

But not able to get the "Domain" information.
Any help on this will be much appreciated.


Shaji:Cool:
 

vansmith

Senior Member
Joined
Oct 19, 2008
Messages
19,924
Reaction score
559
Points
113
Location
Queensland
Your Mac's Specs
Mini (2014, 2018, 2020), MBA (2020), iPad Pro (2018), iPhone 13 Pro Max, Watch (S6)
Are you trying to get the domain information or the MAC address (letter case, in this example, matters quite a bit)? If you're looking for the domain, try document.domain. If you're looking for the MAC address, I fear you may be out of luck - I doubt JavaScript can access that kind of information as the JS engine in your browser of choice is likely sandboxed and too far abstracted from the machine.
 
OP
S
Joined
Feb 19, 2014
Messages
5
Reaction score
0
Points
1
Thank you so much for the response.
We are trying to get the "domain" name only.

I tried as you suggested.

alert($.getenv("document.domain")) but I am getting output as "null".

We are running the JavaScript as a standalone, not through browser.
I there is any other method. Please advice.

Shaji
 

vansmith

Senior Member
Joined
Oct 19, 2008
Messages
19,924
Reaction score
559
Points
113
Location
Queensland
Your Mac's Specs
Mini (2014, 2018, 2020), MBA (2020), iPad Pro (2018), iPhone 13 Pro Max, Watch (S6)
You don't need to use getenv - just straight up document.domain. So,
Code:
alert(document.domain)
 
OP
S
Joined
Feb 19, 2014
Messages
5
Reaction score
0
Points
1
Thanks for the valuable suggestion.

We are not getting the result as expected, it showing "Null".

Shaji
 

vansmith

Senior Member
Joined
Oct 19, 2008
Messages
19,924
Reaction score
559
Points
113
Location
Queensland
Your Mac's Specs
Mini (2014, 2018, 2020), MBA (2020), iPad Pro (2018), iPhone 13 Pro Max, Watch (S6)
When you say "standalone", are you referring to running this locally? If so, that would be why (I would have imagined that it might spit back localhost but null makes a bit of sense).
 
OP
S
Joined
Feb 19, 2014
Messages
5
Reaction score
0
Points
1
yes, we are running this locally.
We have a "ExtendScript Tool Kit CS6" by which we are using to create "javascripts" for applications like, indesign, illustrator etc...

This editor supports all "javascripts" syntax. Our goal is to catch the MAC machine "domain" name before executing the scripts for automation purpose, if the "domain" is not pertaining to our company the subsequent script won't work, this is for security purpose for not hacking our scripts by others.

We have Windows and MAC machines with us. Successfully implemented for windows with the same "syntax" which i posted in my first discussion.

But we are unable to get the domain names in MAC, so I thought of positing it in the MAC forum.

Shaji
 

vansmith

Senior Member
Joined
Oct 19, 2008
Messages
19,924
Reaction score
559
Points
113
Location
Queensland
Your Mac's Specs
Mini (2014, 2018, 2020), MBA (2020), iPad Pro (2018), iPhone 13 Pro Max, Watch (S6)
Try window.location.hostname - that should work for you.

Just as a note - MAC means something different than Mac (this is especially important when talking about networking). The former refers to an identifier for networking interfaces, the latter to the Apple branded machines. I don't normally correct people on this but if you're talking about networking issues, it's important to differentiate the two. :)
 
OP
S
Joined
Feb 19, 2014
Messages
5
Reaction score
0
Points
1
Thank you for your valuable suggestion and responses on this topic.

Since its a "script editor" the syntax which you have given did't work.

We dropped executing it through the "Script Editor". Now we are running it in the "Terminal", which we got the result.

Thanks...

Shaji
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top