?
Solved

How do I delete the home address field (except the zipcode) from AD?

Posted on 2010-11-12
6
Medium Priority
?
290 Views
Last Modified: 2012-05-11
I need to remove the home/work address field in AD but leave the zip code.  We don't want anyone except HR knowing the home addresses of our employees.  Is their a batch file or script that someone can help me with,
0
Comment
Question by:ITPULASKI
[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
6 Comments
 
LVL 57

Expert Comment

by:Mike Kline
ID: 34121534
If you look at this page  http://www.selfadsi.org/user-attributes-w2k3.htm

Are you trying to delete streetaddresss or everything on that tab except for postal code?
0
 

Author Comment

by:ITPULASKI
ID: 34121564
I am trying to delete Street, P.O. Box, City, State/Province except zip which shows up on the 'Address' tab on a user profile in AD.
0
 

Accepted Solution

by:
ITPULASKI earned 0 total points
ID: 34124234
I was able to find a way to delete a single user with this script:

Const ADS_PROPERTY_CLEAR = 1

Set objUser = GetObject _
   ("LDAP://cn=johns smith,ou=contractors,ou=stlouis,dc=axi,dc=aic,dc=com")
 
objUser.PutEx ADS_PROPERTY_CLEAR, "streetAddress", 0
objUser.PutEx ADS_PROPERTY_CLEAR, "postofficebox", 0
objUser.PutEx ADS_PROPERTY_CLEAR, "l", 0
objUser.PutEx ADS_PROPERTY_CLEAR, "st", 0
objUser.PutEx ADS_PROPERTY_CLEAR, "c", 0
objUser.SetInfo

However, I am need to be able to delete multiplle users address information within an OU and I do not know how to do that.  Does anyone?
0
 
LVL 11

Expert Comment

by:Tasmant
ID: 34943182
You can use this code.
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_CLEAR, "streetAddress", 0
		objUser.PutEx ADS_PROPERTY_CLEAR, "postofficebox", 0
		objUser.PutEx ADS_PROPERTY_CLEAR, "l", 0
		objUser.PutEx ADS_PROPERTY_CLEAR, "st", 0
		objUser.PutEx ADS_PROPERTY_CLEAR, "c", 0
		objUser.SetInfo
    objRecordSet.MoveNext
Loop

Open in new window

0
 
LVL 59

Expert Comment

by:Darius Ghassem
ID: 34959222
This question has been classified as abandoned and is being closed as part of the Cleanup Program. See my comment at the end of the question for more details.
0

Featured Post

Office 365 Training for Admins - 7 Day Trial

Learn how to provision tenants, synchronize on-premise Active Directory, implement Single Sign-On, customize Office deployment, and protect your organization with eDiscovery and DLP policies.  Only from Platform Scholar.

Question has a verified solution.

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

A hard and fast method for reducing Active Directory Administrators members.
Had a business requirement to store the mobile number in an environmental variable. This is just a quick article on how this was done.
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…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses

770 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