Dec 282010
 

First post to start off with in regards to Active Directory –
How.

I have used a couple of methods, both with varying degrees of success.

  1. Using ActiveX and command line commands
  2. Using ActiveX and IADs/ADSI

Using the first has the advantage of being able to pass different credentials onto the command, which enables me to run the script as a different user to the one I’m logged in under.
The second method is a bit cleaner to write, but it needs me logged in under a user that has read/write privileges to AD if I want to change anything, but just viewing AD objects is fine however.
Depending on your environment, I have found that either method works. With the first method, you will get command line windows opening up and closing by themselves when executing queries which may or may not annoy you a bit or a lot.

Either way will work though.

Share
Dec 282010
 

I have found being able to ping from a webpage useful on occasion so I thought I would post up a few snippets that I used to ping computers.


var oLoc = new ActiveXObject('WbemScripting.SWbemLocator');
var oSrv = oLoc.ConnectServer(null,'/root/cimv2');
var PingServer = new Enumerator(oSrv.ExecQuery('SELECT * FROM Win32_PingStatus WHERE Address = "' + Computer + '" AND Timeout = 5000'));
PingServer.moveFirst();
var respcode = PingServer.item().StatusCode;
if(respcode == 0) {
alert("Reply from "+Computer)
} else {
alert("Error pinging "+Computer+"\nError Code : "+respcode);
}

That’s pretty much a cut down version of what I use, it’s missing all the HTML obviously but that’s the core of it.
The “Computer” variable is the address or hostname that you want to ping, and “Timeout” is the maximum time before the ping times out in milliseconds.

Now a quick explanation :
First couple of lines creates the ActiveX Object and starts a connection using WMI
Third line creates the Enumerator object that contains the results from the query that returns the ping results.
Fourth and Fifth lines get to the results and returns the Status Code respectively.
From there, a response of 0 means the ping was good, otherwise anything else means it was bad.
This link has the list of status codes and their meanings.

I have used this at work to see if computers are online quickly as I have this and a few other useful scripts running in a little window off to the side.

Share
Dec 262010
 

Screenshots before I’ve prettied it up, which I’ll be doing when I have time 🙁

Share
Dec 262010
 

So I’ve decided to dip my toes into Android programming, and instead of dipping in my toes I’ve jumped into the deep end.
I have started making a program to read my Smartrider value and display it in the app so I can quickly view how much money I have left on my Smartrider.

Will upload some screenshots of the WIP when I get a chance.

Share
Dec 262010
 

I have been making some scripts for work recently and have found that no one seems to use Active Directory and Javascript together.
Some of you, or probably all of you will say “That’s because VBScript is better”, which I don’t particularly agree with.
While VBScript is good in it’s own way, I’m not too familiar with it, and while trying to start scripting I found out that I can’t easily resize, add, or remove elements from arrays, which was something I was doing quite regularly.

So I have decided to create this blog, which I will post up snippets and code that may be a help to anyone trying to manipulate AD with Javascript.

Share