'====================================================================
'= Empty an AD Attribute VBScript sample - Copyright © 2007, Dave Moats
'=
'= This sample is provided 'as-is', without any express or implied warranty.
'= In no event will the authors be held liable for any damages arising from
'= the use of this sample code.
'=
'= Permission is granted to anyone to use this sample code for any purpose,
'= including commercial applications, subject to the following restrictions:
'=
'= The origin of this code must not be misrepresented;
'=       you must not claim that you wrote the original code.
'=       If you use this code, an acknowledgment in the
'=       documentation is requested - shown below:
'=
'= Portions Copyright © 2007, Dave Moats (http://www.davemoats.com/).
'=
'====================================================================
'====================================================================
'==
'==    thie is a script sample that shows how to empty attributes in
'==    Active Directory
'==
'====================================================================

'====================================================================
'== set up the ADs constants we need in this script
'====================================================================
const ADS_ATTR_CLEAR = ( 1)
const ADS_ATTR_DELETE = ( 4)

'====================================================================
'== bind to the user that has the attribute we want to blank
'====================================================================
set usrObj = getobject ( "LDAP://CN=User Account,OU=Accounts,DC=Domain,DC=com")

'====================================================================
'== echo the current description
'====================================================================
wscript.echo usrObj.description

'====================================================================
'== set the description to a blank string
'====================================================================
usrObj.description = " "
usrObj.setinfo

'====================================================================
'== let's see what is in updated description
'====================================================================
wscript.echo usrObj.description

'====================================================================
'== now try to clear the description field
'====================================================================
usrObj.putex ADS_ATTR_CLEAR, "description", ""
usrObj.setinfo

'====================================================================
'== let's see what is in the updated description
'====================================================================
wscript.echo usrObj.description

set usrObj = nothing


Copyright © 2005 - 2013 Dave Moats.  All rights reserved.  Links: Copyright © by their respective owners.
NO WARRANTIES EXTENDED.  Void where prohibited by law.  Please report any issues or broken links.
You may link to this site freely from your own site.  You may quote from this site, but please include a link to the original source on the originating site.