Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2010-11-12
6
Medium Priority
?
298 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

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

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

Had a business requirement to store the mobile number in an environmental variable. This is just a quick article on how this was done.
Compliance and data security require steps be taken to prevent unauthorized users from copying data.  Here's one method to prevent data theft via USB drives (and writable optical media).
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 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…
Suggested Courses

604 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