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
278 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 71

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows the method of using the Resultant Set of Policy Tool to locate Group Policy that applies a particular setting.
Here's a look at newsworthy articles and community happenings during the last month.
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…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

691 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