#145173 - 2005-08-10 01:22 AM
Trouble setting a value to nothing ?
|
Gerald_G
Fresh Scripter
Registered: 2005-04-11
Posts: 34
Loc: Canada
|
I am having trouble setting a user attribute in AD to nothing with Kix. Still running 4.22
I can set the attribute to any text, but get errors trying to set it to nothing.
$adsUser.postOfficeBox = "" $adsUser.setinfo
will not work.
$adsUser.postOfficeBox = "New Text" $adsUser.setinfo
This comes back error free and changes the field to "New Text".
What am I not seeing here ?
Thanks
|
Top
|
|
|
|
#145175 - 2005-08-10 01:36 AM
Re: Trouble setting a value to nothing ?
|
Gerald_G
Fresh Scripter
Registered: 2005-04-11
Posts: 34
Loc: Canada
|
Well.
Still does not change the value in AD, but I get a new error code.
Before I was getting error 9
E_ADS_OBJECT_UNBOUND The specified ADSI object is not bound to a remote resource. Make sure to call GetInfo on a newly created object after SetInfo has been called.
With the $Nothing I get error 16389 Which I don't see in error lists I have found to date.
|
Top
|
|
|
|
#145176 - 2005-08-10 01:39 AM
Re: Trouble setting a value to nothing ?
|
Gerald_G
Fresh Scripter
Registered: 2005-04-11
Posts: 34
Loc: Canada
|
BTW it is not a newly created object. As I noted, I can easily change the text to anything else, just not to nothing.
|
Top
|
|
|
|
#145177 - 2005-08-10 02:38 AM
Re: Trouble setting a value to nothing ?
|
Allen
KiX Supporter
Registered: 2003-04-19
Posts: 4545
Loc: USA
|
I googled a vb snipet and converted it to kix... Totally untested.
Code:
$ads_property_clear=1 $adsUser.putEX $ads_property_clear, "Postofficebox", "" $adsUser.setinfo
|
Top
|
|
|
|
#145179 - 2005-08-10 02:48 AM
Re: Trouble setting a value to nothing ?
|
Allen
KiX Supporter
Registered: 2003-04-19
Posts: 4545
Loc: USA
|
As you wish sir... http://www.dx21.com/SCRIPTING/ADSI/ADGUI/USER2.ASP
...and just for clarification, I never said I was a COM expert.
|
Top
|
|
|
|
#145181 - 2005-08-10 03:54 AM
Re: Trouble setting a value to nothing ?
|
Gerald_G
Fresh Scripter
Registered: 2005-04-11
Posts: 34
Loc: Canada
|
Code:
$adsUser.putEX(1, "Postofficebox", "") $adsUser.setinfo
Yes this works, but of course my next question. What is the difference between Code:
$adsUser.putEX(1, "Postofficebox", "")
and Code:
$adsUser.put("Postofficebox","")
and where can I read about putEX ?
THANKS !
Edited by Gerald_G (2005-08-10 03:57 AM)
|
Top
|
|
|
|
#145185 - 2005-08-10 05:44 PM
Re: Trouble setting a value to nothing ?
|
Gerald_G
Fresh Scripter
Registered: 2005-04-11
Posts: 34
Loc: Canada
|
Thanks guys - I found this info, so I thought I'd post in case someone searches this board for "PutEX".
Quote:
Two ADSI methods, Put and PutEx, are provided for setting attribute values.
You can use the Put method for simple attribute assignment, but not to remove an attribute. Attempts to use the Put method to set the attribute value to null or an empty string (for instance) cause an error. You can use the Put method to set the value of an attribute that can have multiple values, but it replaces any existing values. The syntax for the Put method is as follows:
Object.Put [attribute name], [value]
-or-
Object.[property] = [value]
The PutEx method is more comprehensive, and can be used to assign attribute values, to add or remove values from attributes that can have multiple values, and to clear the value of an attribute. As described above, clearing the attribute has the effect of removing the attribute from the directory structure. The syntax for the PutEx method is as follows:
Object.PutEx [controlcode], [attribute name], [value(s)]
Values for Control Code are:
Const ADS_PROPERTY_CLEAR = 1 Const ADS_PROPERTY_UPDATE = 2 Const ADS_PROPERTY_APPEND = 3 Const ADS_PROPERTY_DELETE = 4
When changing an attribute value, if the attribute can only have a single value, you can use the Put method. The Put method overwrites any existing values. If the attribute can have multiple values and additional values are to be added, use the PutEx method and place the additional values into an array.
NOTE: After using the Put or PutEx method to modify object attribute values, you must explicitly call the SetInfo method to save the changes:
Object.SetInfo
Edited by Chris S. (2005-08-11 01:42 AM)
|
Top
|
|
|
|
#145186 - 2005-08-10 08:06 PM
Re: Trouble setting a value to nothing ?
|
Howard Bullock
KiX Supporter
Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
|
Thanks for the informational post Gerald_G.
You should be aware however that there are many post about PutEx on the board. If you did a search, make sure to change the date range "newer than X years" value. I found a lot of posts (86) that reference PutEx when I set the search for posts up to 4 years old.
|
Top
|
|
|
|
Moderator: Shawn, ShaneEP, Ruud van Velsen, Arend_, Jochen, Radimus, Glenn Barnas, Allen, Mart
|
0 registered
and 515 anonymous users online.
|
|
|