VBscript & Active Directory and printers ? (continued)
Posted on Thursday, 25th October, 2007 in Life
As I posted earlier, I tried working around some limitations in Microsoft’s Active Directory by teaching the script some intelligence.
But, since we recently started using Thin Clients, all the stuff I did with the fancy vbs was just a waste-of-time. Turns out, Windows XP Embedded doesn’t work quite the same as a “normal” Windows XP (that’s where I tested the script on), and it simply dies when running the WMI Query. Bollocks.
So I switched back, utilizing a shortcut in Startup, but pointing to the shortened vbs (see below) instead of the ugly batch file someone wrote.
Set WshNetwork = CreateObject("WScript.Network") WshNetwork.AddWindowsPrinterConnection "\\nas.barfoo.org\Kyocera FS-9100DN KX" ' Set the default printer to something useful WshNetwork.SetDefaultPrinter "\\nas.barfoo.org\Kyocera FS-9120DN KX"
But even that doesn’t work all the time, I still have to figure out why.
VBscript & Active Directory and printers ?
Posted on Saturday, 13th October, 2007 in Life
Well, since our current solution for mapping printers is an ugly batch file, which needs to be put into Startup, I today poked at doing it in VBscript (I know, but it’s less ugly than the batch script, trust me).
As some of you know, printers are only applicable to users (as in you can’t put a startup script onto an OU, which is going to map the printers). So as we store users and the computes in different OU’s in our Active Directory (we do have about 15.000 students), I can’t apply the printer.vbs to the users OU directly either, unless I implement some intelligence into the script itself.
And that’s basically what I did. Since different pools at the university have different DNS suffixes (like pools.rz.barfoo.org, that our or pools.fmz.barfoo.org) and we only want them students to have our printers when they logon at our pool, I just made the script to get the DNS DomainName of the current active interface and compare it against a given pattern.
' The problem is, if you apply something like this the users get the printers regardless whether they ' are at our location or a different one. So we either need to look up the current AD object (this computer), ' or just compare our current DNS suffix/DomainName against a known pattern. ' Now, lets get the DomainName from the WMI-Interface strComputer = "." Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2") Set colNicConfigs = objWMIService.ExecQuery ("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True") For Each objNicConfig In colNicConfigs strDNSDomain = objNicConfig.DNSDomain Next ' Apply some regexp foo, to see if we're at the computing center or not! Dim regexp Set regexp = New RegExp regexp.Pattern = "pools.rz.barfoo.org" if regexp.Test(strDNSDomain) Then 'If so, then lets just connect the printers we need! Set WshNetwork = CreateObject("WScript.Network") WshNetwork.AddWindowsPrinterConnection "\\nas.barfoo.org\Kyocera Mita FS-9100DN KX" ' Set the default printer to something useful WshNetwork.SetDefaultPrinter "\\nas.barfoo.org\Kyocera Mita FS-9100DN KX" End If
Nagios & plugins
Posted on Saturday, 6th October, 2007 in Life
Since we started utilizing Nagios’s power two months ago, I finally came up with a C-based ram-plugin for nagios. The biggest problem I had with the python and perl based plugins, that some distributions (yes, SLES and Debian) don’t install either Python or Perl.
Since I wanted a manageable setup (as in unified code base across all distributions), I wanted it to work without installing too much. So I took the swap plugin and basically removed what wasn’t necessary and voila!
Here we go, yay ME!
Only thing I need to finish sometime soon, is getting the NSClient++ work on my Windows boxen (which I do have quite a few, the domain controllers, nas-cluster, …)