Solved

change Ldap Attribute with Vbscript from many users

Posted on 2011-02-17
1
970 Views
Last Modified: 2012-05-11
Hy everybody

I need to delete an attribute from any Users in the AD of our company. I found this helpful script:

"Const ADS_PROPERTY_CLEAR = 1

Set objUser = GetObject _
   ("LDAP://cn=ken myer, ou=finance, dc=fabrikam, dc=com")
 
objUser.PutEx ADS_PROPERTY_CLEAR, "telephoneNumber", 0
objUser.SetInfo
"

Is there a possibility to say the script, change the attribute of ALL users in the specified OU?

Thanks for any help.
0
Comment
Question by:axega
1 Comment
 
LVL 11

Accepted Solution

by:
Tasmant earned 500 total points
ID: 34917511
On Error Resume Next
Const ADS_PROPERTY_CLEAR = 1
strOU = "LDAP://OU=MyOU,DC=domain,DC=com"

'Set rootDSE = GetObject("LDAP://RootDSE")
'strDomain = "LDAP://" & rootDSE.Get("defaultNamingContext")

strfilter = "(&(objectCategory=Person)(objectClass=User))"
strAttributes = "adspath"
strScope = "onelevel"

Set objConnection = CreateObject("ADODB.Connection")
Set objcommand = CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
objcommand.ActiveConnection = objConnection

objCommand.Properties("Page Size") = 1000
objCommand.Properties("Timeout") = 600
objCommand.Properties("Cache Results") = True

'Execute Query
objCommand.CommandText = "<" & strOU & ">;" & strFilter & ";" & strAttributes & ";" & strScope
Set objRecordSet = objCommand.Execute

Do Until objRecordSet.EOF
      Set objUser = GetObject(objRecordSet.Fields("adspath").Value)
        objUser.PutEx ADS_PROPERTY_CLEA R, "telephoneNumber", 0
        objUser.SetInfo
      objRecordSet.MoveNext
Loop
0

Featured Post

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

Resolve DNS query failed errors for Exchange
This article runs through the process of deploying a single EXE application selectively to a group of user.
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 Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …

809 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