Page 1 of 1 1
Topic Options
#207440 - 2013-07-15 09:48 PM Shell to a Variable
zrdean Offline
Fresh Scripter

Registered: 2011-03-04
Posts: 5
Loc: Carrollton, Kentucky, USA
I think this is my first post here. I've been using KiXtart for about 10 years. The person whom I worked under for 5 years used it religiously, and now I do as well on my own K-12 (Education) network. I love it.

Enough of that. I've hit a bit of a brick wall. I'm not sure if this question needs to be in basic scripting, advanced scripting, noobie scripting, No clue.

My AD has some custom attributes in it that are managed by my state department. I am trying to set a value of one of these attributes to "true" and I cannot get it to work.

Here's the code:
-----------------------
$ADCN = shell '$cmd dsquery user -samid $username'
$obj=getobject("LDAP://$ADCN")
$obj.ketsEduHidden = 'TRUE'
$obj.SetInfo
-----------------------

Basically, I'm wanting to set the output of the dsquery command as the variable $adcn.

Can someone please steer me in the right direction? Thanks again so much!

Top
#207441 - 2013-07-15 10:36 PM Re: Shell to a Variable [Re: zrdean]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4562
Loc: USA
To answer your question, see ...

WSHPipe -
http://www.kixtart.org/forums/ubbthreads.php?ubb=showflat&Number=83201

How to use UDFs -
http://www.kixtart.org/forums/ubbthreads.php?ubb=showflat&Number=81943#Post81943

The rest of the UDFs are here -
http://www.kixtart.org/forums/ubbthreads.php?ubb=postlist&Board=7&page=1


Keep in mind, this should be doable within the kix code itself. One such UDF that may take care of it is...

ADProperty -
http://www.kixtart.org/forums/ubbthreads.php?ubb=showflat&Number=202261#Post202261

I think if you do a search of the UDFs and the board, you will find plenty of examples.

Top
#207442 - 2013-07-15 11:15 PM Re: Shell to a Variable [Re: Allen]
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2127
Loc: Tulsa, OK
I'm not familiar with dsquery...

but if you could provide an example of what that shell is expected to return exactly, I'm willing to bet there is an all Kix method of getting it. Eliminating the need to shell out to the command prompt all together.

Top
#207443 - 2013-07-15 11:22 PM Re: Shell to a Variable [Re: ShaneEP]
zrdean Offline
Fresh Scripter

Registered: 2011-03-04
Posts: 5
Loc: Carrollton, Kentucky, USA
Shane, from that command, dsquery should return "CN=Objectname,OU=Staff,DC=subdomain,DC=example,DC=net" which is what I need to set the "ketsEduHidden" value to "True".


Allen, thank you for your prompt response. I will look into this now.


Edited by zrdean (2013-07-15 11:23 PM)

Top
#207444 - 2013-07-16 12:17 AM Re: Shell to a Variable [Re: zrdean]
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2127
Loc: Tulsa, OK
Perhaps the GetUserDN() would suffice?

 Code:
$ADCN = getUserDN()
$obj=getobject("LDAP://"+$ADCN)
$obj.ketsEduHidden = 'TRUE'
$obj.SetInfo

Function getUserDN(optional $username)
  Dim $objTrans
  if $username=""
    $username=@ldomain + "\"+ @userid
  endif
  if not instr($username,"\")
    $username=@ldomain + "\" + $username
  endif
  $objTrans = CreateObject("NameTranslate")
  if @error
    exit @error
  else
    $objTrans.Init(3, "")
    $objTrans.Set(3,$username)
    $getUserDN = $objTrans.Get(1)
    if @error
      exit @error
    endif
  endif
EndFunction

Top
#207445 - 2013-07-16 01:17 AM Re: Shell to a Variable [Re: ShaneEP]
zrdean Offline
Fresh Scripter

Registered: 2011-03-04
Posts: 5
Loc: Carrollton, Kentucky, USA
You are wonderful. With a minor tweak, that did exactly what I needed! Thank you so much.
Top
#207446 - 2013-07-16 01:48 AM Re: Shell to a Variable [Re: zrdean]
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2127
Loc: Tulsa, OK
Great!
Top
Page 1 of 1 1


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

Who's Online
0 registered and 874 anonymous users online.
Newest Members
StuTheCoder, M_Moore, BeeEm, min_seow, Audio
17884 Registered Users

Generated in 0.057 seconds in which 0.026 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