MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.
' Change the following line to the OU you want to hide strOUpath = "****" ' This will do the target OU and everything under it Const ADS_SCOPE_BASE = 0 Set objConnection = CreateObject("ADODB.Connection") Set objCommand = CreateObject("ADODB.Command") objConnection.Provider = "ADsDSOObject" objConnection.Open "Active Directory Provider" Set objCommand.ActiveConnection = objConnection objCommand.Properties("Page Size") = 1000 objCommand.Properties("Searchscope") = ADS_SCOPE_BASE objCommand.CommandText = "SELECT ADsPath, objectClass, objectCategory FROM 'LDAP://" & strOUpath & "'" Set objRecordSet = objCommand.Execute objRecordSet.MoveFirst Do Until objRecordSet.EOF strClass = objRecordSet.Fields("objectClass").Value strCategory = objRecordSet.Fields("objectCategory").Value If strClass = "user" OR strCategory = "person" Then strUserPath = objRecordSet.Fields("ADsPath").Value Set objUser = GetObject(strUserPath) objUser.MSExchHideFromAddressLists = TRUE objUser.SetInfo End If objRecordSet.MoveNext Loop
Add your voice to the tech community where 5M+ people just like you are talking about what matters.
Join the community of 500,000 technology professionals and ask your questions.