Page 1 of 1 1
Topic Options
#198012 - 2010-03-09 06:44 PM Possible "attribute with hyphen" bug
Christoph_Peus Offline
Fresh Scripter

Registered: 2007-05-14
Posts: 5
Hi experts,

a command like this:

$User.uwh-department1 = $value

doesn't work in Kixtart, because Kixtart does not recognize the hyphen as part of the attributes name. You will get an error message:

ERROR : unknown command [department1]!

I think this should work, as hyphens are used in default Active Directory attribute names as well.
But for the moment I would really appreciate a hint for a workaround, cause I've created several new attributes in the Active Directory Schema, which cannot be deleted or name-changed afterwards!!!

Thank you!

Christoph

Top
#198013 - 2010-03-09 08:45 PM Re: Possible "attribute with hyphen" bug [Re: Christoph_Peus]
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4562
Loc: USA
As you've seen, the hypen is used for subtraction in kix. Unless someone knows a way to escape/force the hypen, you might be able to use execute to make it work.

Untested, each of these is slightly different, so try and see how different ones work:
 Code:
$RC=execute("$$User.uwh" + "-" + "department1=" + $value) 
$RC=execute("$$User.uwh-department1=" + $value)
$RC=execute("$" + "User.uwh-department1=" + $value)


Edited by Allen (2010-03-09 08:58 PM)

Top
#198033 - 2010-03-11 07:55 AM Re: Possible "attribute with hyphen" bug [Re: Allen]
Christoph_Peus Offline
Fresh Scripter

Registered: 2007-05-14
Posts: 5
Hi Allen,

thanks for your fast reply! I tried all of these but unfortunately none worked. I guess that the source of the problem is the Kixtart execution routine itself, not the parsing of the source code.

I worked around the problem for now with "ldifde", which writes a properly prepared LDIF file to the Active Directory LDAP server, but this is too inconvenient to take this as a general solution. I think Kixtart should be modified to allow commands with hyphen, at least when the command is COM related.
Since I will have to write several scripts which work with this type of LDAP attribute shortly, I fear that I will have to use another scripting language. Sigh...

Regards
Christoph

Top
#198036 - 2010-03-11 01:38 PM Re: Possible "attribute with hyphen" bug [Re: Christoph_Peus]
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
Unfortunately the interpreter cannot work with operators in properties or any other type of unprotected string including things like file paths.

The work-around (if the object supports it) is to reference the property through a collection as a proper string, something like:
 Code:
$User.fields("uwh-department1").Value = $value

or
 Code:
$User.properties("uwh-department1").Value = $value


Obviously the "fields"/"properties" depends on the object definition.

Top
#198037 - 2010-03-11 02:29 PM Re: Possible "attribute with hyphen" bug [Re: Richard H.]
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4562
Loc: USA
How many attributes are we talking here? No option to rename them without a hypen, and use something like the underscore?
Top
#198038 - 2010-03-11 03:20 PM Re: Possible "attribute with hyphen" bug [Re: Allen]
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
Here is an example of how to GET the value for a troublesome property with an operator in the name:
 Code:
Break ON
 
$objSysInfo = CreateObject("ADSystemInfo") 
$strUserDN = $objSysInfo.userName 
$oADObject = GetObject("LDAP://" + $strUserDN)

$sAttribute="uwh-department1"
"Current value of '"+$sAttribute+"'="+$oADObject.Get($sAttribute)+@CRLF


The corresponding action to write a property is .Put() or .PutEx() followed by .SetInfo()

More information here: http://msdn.microsoft.com/en-us/library/aa705950(VS.85).aspx


Edited by Richard H. (2010-03-11 03:25 PM)
Edit Reason: Changed term "attribute" to "property" as it's more appropriate

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 456 anonymous users online.
Newest Members
M_Moore, BeeEm, min_seow, Audio, Hoschi
17883 Registered Users

Generated in 0.059 seconds in which 0.027 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