Solved

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

Posted on 2010-11-12
6
260 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
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

Control application downtime with dependency maps

Visualize the interdependencies between application components better with Applications Manager's automated application discovery and dependency mapping feature. Resolve performance issues faster by quickly isolating problematic components.

Question has a verified solution.

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

In this article, we will see the basic design consideration while designing a Multi-tenant web application in a simple manner. Though, many frameworks are available in the market to develop a multi - tenant application, but do they provide data, cod…
Possible fixes for Windows 7 and Windows Server 2008 updating problem. Solutions mentioned are from Microsoft themselves. I started a case with them from our Microsoft Silver Partner option to open a case and get direct support from Microsoft. If s…
This tutorial will walk an individual through the steps necessary to enable the VMware\Hyper-V licensed feature of Backup Exec 2012. In addition, how to add a VMware server and configure a backup job. The first step is to acquire the necessary licen…
This tutorial will walk an individual through configuring a drive on a Windows Server 2008 to perform shadow copies in order to quickly recover deleted files and folders. Click on Start and then select Computer to view the available drives on the se…

863 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

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now