New To Mac-Forums?

Welcome to our community! Join the discussion today by registering your FREE account. If you have any problems with the registration process, please contact us!

Get your questions answered by community gurus Advice and insight from world-class Apple enthusiasts Exclusive access to members-only contests, giveaways and deals

Join today!

 
Start a Discussion
 

Mac-Forums Brief

Subscribe to Mac-Forums Brief to receive special offers from Mac-Forums partners and sponsors

Join the conversation RSS
Apple Desktops Discussion of Apple's desktop machines including Mac Pro, iMac, Power Mac, and mini

How to Get Domain Information using Javascripting


Post Reply New Thread Subscribe

 
Thread Tools
Shaji

 
Member Since: Feb 19, 2014
Posts: 5
Shaji is on a distinguished road

Shaji is offline
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
QUOTE Thanks
vansmith

 
vansmith's Avatar
 
Member Since: Oct 19, 2008
Location: Toronto
Posts: 17,669
vansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond repute
Mac Specs: 2012 13" MBP (2.5 i5, 8GB)

vansmith is offline
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.

Important Links: Community Guidelines : Use the reputation system if you've been helped.
M-F Blog :: Write for the blog
Personal Twitter
QUOTE Thanks
Shaji

 
Member Since: Feb 19, 2014
Posts: 5
Shaji is on a distinguished road

Shaji is offline
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
QUOTE Thanks
vansmith

 
vansmith's Avatar
 
Member Since: Oct 19, 2008
Location: Toronto
Posts: 17,669
vansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond repute
Mac Specs: 2012 13" MBP (2.5 i5, 8GB)

vansmith is offline
You don't need to use getenv - just straight up document.domain. So,
Code:
alert(document.domain)

Important Links: Community Guidelines : Use the reputation system if you've been helped.
M-F Blog :: Write for the blog
Personal Twitter
QUOTE Thanks
Shaji

 
Member Since: Feb 19, 2014
Posts: 5
Shaji is on a distinguished road

Shaji is offline
Thanks for the valuable suggestion.

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

Shaji
QUOTE Thanks
vansmith

 
vansmith's Avatar
 
Member Since: Oct 19, 2008
Location: Toronto
Posts: 17,669
vansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond repute
Mac Specs: 2012 13" MBP (2.5 i5, 8GB)

vansmith is offline
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).

Important Links: Community Guidelines : Use the reputation system if you've been helped.
M-F Blog :: Write for the blog
Personal Twitter
QUOTE Thanks
Shaji

 
Member Since: Feb 19, 2014
Posts: 5
Shaji is on a distinguished road

Shaji is offline
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
QUOTE Thanks
vansmith

 
vansmith's Avatar
 
Member Since: Oct 19, 2008
Location: Toronto
Posts: 17,669
vansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond reputevansmith has a reputation beyond repute
Mac Specs: 2012 13" MBP (2.5 i5, 8GB)

vansmith is offline
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.

Important Links: Community Guidelines : Use the reputation system if you've been helped.
M-F Blog :: Write for the blog
Personal Twitter
QUOTE Thanks
Shaji

 
Member Since: Feb 19, 2014
Posts: 5
Shaji is on a distinguished road

Shaji is offline
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
QUOTE Thanks

Post Reply New Thread Subscribe


« RAM issue | Printing 2 x 4 address labels - HOW? »
Thread Tools

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread
Thread Starter
Forum
Replies
Last Post
Issue with iMac bound to AD failing to maintain domain link muddyfox OS X - Operating System 5 04-03-2011 08:02 PM
My Macbook is attempting to authenticate with my school's domain w/o authorization walmartconnect Internet, Networking, and Wireless 19 03-17-2009 05:48 PM
Recording information problem with iTunes 8.0.1 schwine Music, Audio, and Podcasting 0 11-25-2008 11:56 AM
own domain publishing using .mac ferritt Web Design and Hosting 1 08-21-2007 09:22 PM
My Mac is trying to log into my school's domain w/o authorization? walmartconnect OS X - Operating System 2 11-03-2006 10:50 AM

All times are GMT -4. The time now is 12:16 AM.

Powered by vBulletin
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
X

Welcome to Mac-Forums.com

Create your username to jump into the discussion!

New members like you have made this community the ultimate source for your Mac since 2003!


(4 digit year)

Already a member?