Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

change Ldap Attribute with Vbscript from many users

Posted on 2011-02-17
1
Medium Priority
?
978 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
[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
1 Comment
 
LVL 11

Accepted Solution

by:
Tasmant earned 2000 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Group policies can be applied selectively to specific devices with the help of groups. Utilising this, it is possible to phase-in group policies, over a period of time, by randomly adding non-members user or computers at a set interval, to a group f…
Let's recap what we learned from yesterday's Skyport Systems webinar.
This tutorial will walk an individual through the process of configuring their Windows Server 2012 domain controller to synchronize its time with a trusted, external resource. Use Google, Bing, or other preferred search engine to locate trusted NTP …
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

618 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