Solved

change Ldap Attribute with Vbscript from many users

Posted on 2011-02-17
1
974 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 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

Free NetCrunch network monitor licenses!

Only on Experts-Exchange: Sign-up for a free-trial and we'll send you your permanent license!

Here is what you get: 30 Nodes | Unlimited Sensors | No Time Restrictions | Absolutely FREE!

Act now. This offer ends July 14, 2017.

Question has a verified solution.

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

While rebooting windows server 2003 server , it's showing "active directory rebuilding indices please wait" at startup. It took a little while for this process to complete and once we logged on not all the services were started so another reboot is …
Active Directory security has been a hot topic of late, and for good reason. With 90% of the world’s organization using this system to manage access to all parts of their IT infrastructure, knowing how to protect against threats and keep vulnerabil…
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 …
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 …

705 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