Solved

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

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

Join & Write a Comment

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…
Disabling the Directory Sync Service Account in Office 365 will stop directory synchronization from working.
This tutorial will show how to configure a new Backup Exec 2012 server and move an existing database to that server with the use of the BEUtility. Install Backup Exec 2012 on the new server and apply all of the latest hotfixes and service packs. The…
This tutorial will walk an individual through setting the global and backup job media overwrite and protection periods in Backup Exec 2012. Log onto the Backup Exec Central Administration Server. Examine the services. If all or most of them are stop…

746 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

11 Experts available now in Live!

Get 1:1 Help Now