Page 1 of 1 1
Topic Options
#156314 - 2006-01-30 10:34 PM Problem with ADSI
Wildo69 Offline
Fresh Scripter

Registered: 2003-05-07
Posts: 6
ok, am getting an error on the following line
Code:

$objUser.Put "UserAccountControl", $newFlag


Error is "ERROR: Unexpected command"

here is the whole script (minus the actuall UDFs, but can post them if needed)
Code:

Break on

$sWhat = "Name","distinguishedName"
;$sFrom = "LDAP://OU=Security,OU=TMG,OU=IT,OU=CorpHQ,DC=handleman,DC=com"
$sFrom = "LDAP://OU=LAN,OU=PC Support,OU=TMG,OU=IT,OU=CorpHQ,DC=handleman,DC=com"
$sFilter = "(&(objectCategory=person)(objectClass=user)(userAccountControl:1.2.840.113556.1.4.803:=32))"

$aResults = fnLDAPQuery($sWhat,$sFrom,$sFilter,"Name")
@ERROR " | " @SERROR ??
For $r = 0 to Ubound($aResults,1)
$objUser = GetObject("LDAP://"+$aResults[$r,1])

;Region Change value
$flag = $objUser.Get("UserAccountControl")
$newFlag = $flag - 32

$objUser.Put "UserAccountControl", $newFlag
;$objUser.SetInfo
If Not @ERROR
$objUser.Name + " has been fixed." ?
Else
@ERROR " | " @SERROR ?
EndIf
Next

Get $



i am very new to using COM and ADSI, so any help as to why i get this error would be much appreciated

Top
#156315 - 2006-01-30 11:21 PM Re: Problem with ADSI
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22343
Loc: OK
put is a method/function.
try this:
$objUser.Put("UserAccountControl", $newFlag)
_________________________
!

download KiXnet

Top
#156316 - 2006-01-31 04:59 PM Re: Problem with ADSI
Wildo69 Offline
Fresh Scripter

Registered: 2003-05-07
Posts: 6
that worked, awesome...
thanks so much for the help

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 170 anonymous users online.
Newest Members
dimi575, Drecksnacken, Nlill, webtools321, multiman
17734 Registered Users

Generated in 0.029 seconds in which 0.011 seconds were spent on a total of 12 queries. Zlib compression enabled.

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