Page 1 of 1 1
Topic Options
#145173 - 2005-08-10 01:22 AM Trouble setting a value to nothing ?
Gerald_G Offline
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
#145174 - 2005-08-10 01:27 AM Re: Trouble setting a value to nothing ?
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
well, "" will set the value to zerolength string.
there is no nothing available in kix.
you could try:
Code:

dim $nothing
$adsUser.postOfficeBox = $nothing
$adsUser.setinfo



but I have no idea will that kinda work.
as always with com, it goes to the guessing side.
_________________________
!

download KiXnet

Top
#145175 - 2005-08-10 01:36 AM Re: Trouble setting a value to nothing ?
Gerald_G Offline
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 Offline
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 Administrator Online   shocked
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
#145178 - 2005-08-10 02:41 AM Re: Trouble setting a value to nothing ?
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
sure it's untested as it's not kix syntax.
something more like:
Code:

$adsUser.putEX(1, "Postofficebox", "")
$adsUser.setinfo



but that looks little odd too.
alpo, could you post the source?
_________________________
!

download KiXnet

Top
#145179 - 2005-08-10 02:48 AM Re: Trouble setting a value to nothing ?
Allen Administrator Online   shocked
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
#145180 - 2005-08-10 02:55 AM Re: Trouble setting a value to nothing ?
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
hmm...
indeed, it looks pretty same now.
wonder will someone try it out too

and btw, who did speak about com expert?
we have shawn for that stuff. I think the issue here was about conversion of vbs arguments to kixtart args.
_________________________
!

download KiXnet

Top
#145181 - 2005-08-10 03:54 AM Re: Trouble setting a value to nothing ?
Gerald_G Offline
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
#145182 - 2005-08-10 04:01 AM Re: Trouble setting a value to nothing ?
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
well, all the adsi stuff is in the adsi reference of http://msdn.microsoft.com

the difference between put an putEx is the obvious Ex as in Extended.
and in this case the argument to specify if the value is wished to be emptied.
_________________________
!

download KiXnet

Top
#145183 - 2005-08-10 06:47 AM Re: Trouble setting a value to nothing ?
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4545
Loc: USA
All I meant was I never know what the syntax is going to be for com objects without testing it... it seems like sometimes its with parenthesis, and sometimes it isn't.

The best thing is we got him a solution.

Top
#145184 - 2005-08-10 07:46 AM Re: Trouble setting a value to nothing ?
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
Allen, ja, sure, I'm with ya.

as a side note, it never is without paranthesis with kixtart
_________________________
!

download KiXnet

Top
#145185 - 2005-08-10 05:44 PM Re: Trouble setting a value to nothing ?
Gerald_G Offline
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 Offline
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.
_________________________
Home page: http://www.kixhelp.com/hb/

Top
Page 1 of 1 1


Moderator:  Shawn, ShaneEP, Ruud van Velsen, Arend_, Jochen, Radimus, Glenn Barnas, Allen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 515 anonymous users online.
Newest Members
gespanntleuchten, DaveatAdvanced, Paulo_Alves, UsTaaa, xxJJxx
17864 Registered Users

Generated in 0.07 seconds in which 0.028 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org