How to enable and disable a Windows domain account using vb script. In our network there are only 2 people who are able to add or manipulate domain users. Every now and then I have wanted to give a non administrator user the ability to enable or disable a user account.
In our case we have a couple of domain user accounts used for external software support companies that VPN into our network to perform tasks. I didnâ€™t want that account being open and accessible all of the time. I realize I could have used logon hours within the account properties to specify what hours the user could and couldnâ€™t log on, but I wanted to the account to only be enabled when the support personel asked for access. I didnâ€™t want to add the person I wanted to be able to enable and disable this account to the domain administratorâ€™s group and I didnâ€™t want to have to install the domain administration tools on their PC so they could do this locally.
After some research I found a really easy way to accomplish this using VB Script. The user that will be running the script will have to have security privileges on the user that they are going to be able to enable or disable. Create a text file and name it whatever you want with .vbs as the extension. Edit the following text in the appropriate places and copy this text into the .vbs file.
Set objUser = GetObject _
objUser.AccountDisabled = FALSE
Replace accountname with the user account name, replace organizationalunit with the appropriate organizational unit, domain and domain extension. Save the text file.
Just double click it to execute and viola! Now this is just the bare minimum coding to enable a disabled account it doesnâ€™t come back and let you know it worked or didnâ€™t work. You could get fancy and make it display a message box when itâ€™s finished, but I didnâ€™t feel like going that far.
The following code disables the specified account.
Const ADS_UF_ACCOUNTDISABLE = 2
Set objUser = GetObject _
(“LDAP://cn= accountname,ou= organizationalunit,dc= domain,dc= domainextension “)
intUAC = objUser.Get(“userAccountControl”)
objUser.Put “userAccountControl”, intUAC OR ADS_UF_ACCOUNTDISABLE
For added security I took the disable account code and made a scheduled task on one of our servers to automatically run this script every day at 4:30pm. That way I know the account gets disabled and donâ€™t have to worry about someone forgetting to disable it.
These 2 sites may be old hat to you but at some point in all of our IT careers we come across websites that we haven’t used before. One such invaluable website for tracking down problems with web hosting, email hosting or other such services is DNSReport.com.
Running your domain through this will give you all the information you need to see what’s working or not working with your domain. The domain name system (DNS) is the way we translate easy to remember domains (ie. www.misguys.com) to the IP address of where that domain resides. How about having to say “goto 22.214.171.124 or whas is 133?” to direct someone to your website? DNSReport.com has helped us numerous times track down problems and return the aggitated network users back to normalacy. Or as close as we can to normalacy that is.
The second useful website is What Is My IP.com How many times have you tried to find out what IP address a remote user is assigned to only to end up ready to go to the remote site and permanently remove the remote user? It’s much easier to say “open Internet Explorer (not that I use IE, but the majority of the users you will deal with do) and type www.whatismyip.com in the address bar.” Usually the next thing you have to say is “no, not the search bar of google or MSN, but the address bar.” Like I said these may be old hat to you but at some time in your distinguished IT career it wasn’t. Somewhere out there there’s some worn out person trying to track down some problems and these two websites are a couple of pieces to getting the puzzle figured out.
I found this definition from dictionary.com Insisting capriciously on getting just what one wants; difficult to please; It’s the definition of finicky.
Some might say that I am the definition of finicky when it comes to handheld devices. I held out a while before getting my first handheld, they seemed only for those who actually had enough contacts and appointments to keep track of. Then I started seeing the number and breadth of applications available, so I decided it was time.
Consider this taken from the palmOne website, The PalmPilot was invented in 1994 by Jeff Hawkins who founded Palm Computing and is now palmOne’s Chief Technology Office. So, my first handheld was a Handspring Visor in 2001. I tried to go thrifty by getting an open box, bottom-of-the-line model. That lasted about a day as I quickly realized I wanted more storage for all of the applications out there that I would never actually use. So I got the next model up with more memory. One of my co-workers had a color model and I had to have that. So I got a Handspring Prism and used it for about 6 months. Then I discovered the Sony Clie. I got the 615c, but the 655c came out the following week and it played MP3s! So I returned to Best Buy, they exchanged it and I paid the difference. I used it for about 6 months and had wander lust again. I had never really liked the design of the Palm brand until I saw the Tungsten T3. It had the bottom section that slid up and down. I liked it and used it for a good 6 months. I had never cared for the size of most Pocket PC handhelds, but now they had come out with several models that were the same size as the Palm OS based models.
So, I went with a HP 4155 and I have to say that out of the Pocket PC’s it was the best for features and size. I used it for about 6 months (see a trend here?) and again was overcome by the desire for something new. Pathetic, I know. So, I went with the HP RX3715. I never really cared for it. Buying on the internet has it’s downside sometimes. It was big and bulky and it didn’t last too long. I decided I missed the Palm OS and went with a Tungsten T5. For features it was ok, but I really missed the Wi-Fi that the HP 4155 had. I didn’t like how the T5 felt in my hand either. (Remember the definition of finicky?) Then came the Lifedrive. I had read about it and the rumors as to it’s specs and thought “I gotta have that!” It came out around the middle of May and I had mine in my hot little hands the following week. I really like it. It fits perfectly in the hand. The 4gig of space provided by the microdrive inside is awesome. Plus I have a 1gig SD card, so I’m not hurting for space. The Wi-Fi works flawlessly and MP3s sound great on it. I even sold my 30gig iPod Photo because I didn’t want another device to carry around. Not that it compares to the iPod for it’s user interface or storage, but for my needs it’s perfect. Complaints, yeah I have a couple. There are delays when launching applications, especially for the first time after a soft reset. If I’m listening to music and I hop to another application it causes serious hiccups in the playback. The headphone jack is at the bottom of the device, so I have to put it in it’s leather carrying case upside down to avoid removing the headphone cord each time I want to remove it from the case.
The life drive is not a revolution in handhelds, all of it’s features have been around for sometime. It needs some improvement on handling of the hard drive, maybe this will be addressed by Palm OS 6. The thickness could be reduced some. I am surprised that there is not more heat associated with the hard drive than there is. I only gets warm if you do a lot of transferring of files to the hard drive. Overall I am well pleased with the Lifedrive. Check back with me in 6 months and see if there’s anything that’s peaked my interest enough to switch. If you are wondering where the title for the article came from I just saw War of the Worlds. I really liked it and thought Tom Cruise and Dakota Fanning did awesome jobs. Go see it.- jason