#207440 - 2013-07-15 09:48 PM
Shell to a Variable
|
zrdean
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
KiX Supporter
   
Registered: 2003-04-19
Posts: 4562
Loc: USA
|
|
|
Top
|
|
|
|
#207443 - 2013-07-15 11:22 PM
Re: Shell to a Variable
[Re: ShaneEP]
|
zrdean
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
MM club member
   
Registered: 2002-11-29
Posts: 2127
Loc: Tulsa, OK
|
Perhaps the GetUserDN() would suffice?
$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
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
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 342 anonymous users online.
|
|
|