Solved

How I create a script to restrict computer acces filling the "Log On To" ("userWorkstations") field, from a text file

Posted on 2009-05-19
3
232 Views
Last Modified: 2012-05-07
Hello my dear experts,
I use this script to fill the "Log on To" field on AD:
Set objUser = GetObject _
  ("LDAP://cn=user (USR),ou=3rd OU,ou=2nd,ou=1st ou,dc=bpco,dc=com")
 objUser.Put "userWorkstations", "A,B,C,D,E"
objUser.SetInfo
Because of frequent changes inside the net, a very cool improvement will be to be able to use this same script, but allowing to pull the userWorkstations from a file text with a pre-defined computer ser list
Can you help me?
0
Comment
Question by:bpco
  • 2
3 Comments
 
LVL 70

Accepted Solution

by:
Chris Dent earned 125 total points
ID: 24431336

Hey,

Should be pretty straight-forward.

Const WORKSTATION_FILE = "TheList.txt"

Dim objFSO : Set objFSO = CreateObject("Scripting.FileSystemObject")
Dim objFile : Set objFile = objFSO.OpenTextFile(WORKSTATION_FILE, 1, False, 0)

strWorkstations = objFile.ReadAll()

Now it's just down to how you want the file to be formatted. If it's just a list it can be popped straight in:

Set objUser = GetObject _
  ("LDAP://cn=user (USR),ou=3rd OU,ou=2nd,ou=1st ou,dc=bpco,dc=com")
objUser.Put "userWorkstations", strWorkstations
objUser.SetInfo

Where the list in the file would be:

workstation1,workstation2,workstation3

Chris
0
 

Author Comment

by:bpco
ID: 24441046
Worked very well, thanks Chris!
0
 

Author Comment

by:bpco
ID: 24502374
I've should added more points if there were more solutions, like using csv tables for example instead of plain txt files... however, I've got the script well running
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Resolve DNS query failed errors for Exchange
In this article, we will see the basic design consideration while designing a Multi-tenant web application in a simple manner. Though, many frameworks are available in the market to develop a multi - tenant application, but do they provide data, cod…
This tutorial will walk an individual through the steps necessary to join and promote the first Windows Server 2012 domain controller into an Active Directory environment running on Windows Server 2008. Determine the location of the FSMO roles by lo…
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles to another domain controller. Log onto the new domain controller with a user account t…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now