Mass attribute change within AD user accounts

D

David Hodgson

Hi folks,

I'd like to change an attribute in all my active directory user
accounts, or possibly confine the change to certain OU's. The change
must remove the "Terminal Server" user profile setting from each user
account. I don't want to have to manually go in and change every user,
how do I do it?

many thanks
Dave
 
B

Brian Desmond [MVP]

Dave-

This particular set of properties is a PITA to deal with. ADModify.Net (free
tool from MS) is probably a good bet for this.

--
Thanks,
Brian Desmond
Windows Server MVP - Directory Services

www.briandesmond.com
 
J

jwalter

Hi folks,

I'd like to change an attribute in all my active directory user
accounts, or possibly confine the change to certain OU's. The change
must remove the "Terminal Server" user profile setting from each user
account. I don't want to have to manually go in and change every user,
how do I do it?

many thanks
Dave

this did it for me...its VB script embedded in MSAccess, so i can feed
a list of usernames and track the results if needed (note this is just
a code snippet without a lot of error checking etc..). Also, i have
the users full ADSpath already saved, so i dont need to look it up
each time, but the code below will do it for you.

Function removetermservices()
' turns off terminal services access to all users in inputted table

Dim xuser As IADsUser
Set db = CurrentDb
Set rs = db.OpenRecordset("select * from tsourceADCurrentusers order
by finalADusername", dbOpenDynaset)


Do While Not rs.EOF
varadspath=getADSpath(rs("username"))
Set xuser = GetObject(varadspath)
Debug.Print xuser.Name
xuser.AllowLogon = 0
xuser.SetInfo
rs.movenext
Loop

End Function

Function getADSpath(varADName)
Set objconn = CreateObject("ADODB.connection")
objconn.Provider = "ADSDSOObject"
objconn.open "Active Directory Provider"

strbase = "<LDAP://dc=abc,dc=xyz,dc=com>;" ' enter your own
domain here,
strfilter = "(&(Objectclass=USER)(samaccountname=" & varADName
& "));"
strattrs = "adspath,cn;"
strscope = "subtree"
' Debug.Print strbase & strfilter & strattrs & strscope
Set objrs = objconn.Execute(strbase & strfilter & strattrs &
strscope)
If Not objrs.EOF Then
getADSPath = objrs("adspath")
End If

End Function
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top