#157392 - 2006-02-17 03:20 PM
Re: ADS_USER_FLAG --- How to manipulate the right to change password ?
|
Richard H.
Administrator
   
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
Here you go: Code:
$ADS_UF_PASSWORD_CANT_CHANGE=&40 $oUser = GetObject("WinNT://ACME/rhowarth,user") $oUser.Put("UserFlags",$oUser.Get("UserFlags")^$ADS_UF_PASSWORD_CANT_CHANGE)
Note, you will need a recent version of KiXtart for the XOR "^" operator.
|
|
Top
|
|
|
|
#157393 - 2006-02-17 03:30 PM
Re: ADS_USER_FLAG --- How to manipulate the right to change password ?
|
Jochen
KiX Supporter
   
Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
|
|
|
Top
|
|
|
|
#157396 - 2006-02-17 04:18 PM
Re: ADS_USER_FLAG --- How to manipulate the right to change password ?
|
Richard H.
Administrator
   
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
Probably easier to just use a conditional: Code:
function ADS_PWChangeRight($usr, $domain, $Right) dim $objUsr, $_, $UserFlags dim $ADS_UF_PASSWORD_CANT_CHANGE $ADS_UF_PASSWORD_CANT_CHANGE=&40 $objUsr = getobject("WinNT://" + $domain + "/" + $usr + ",user") if not @error $UserFlags = $objUsr.Get("UserFlags") if not $Right $UserFlags = $UserFlags | $ADS_UF_PASSWORD_CANT_CHANGE else If ($UserFlags & $ADS_UF_PASSWORD_CANT_CHANGE) $UserFlags = $UserFlags ^ $ADS_UF_PASSWORD_CANT_CHANGE EndIf endif $objUsr.Put("UserFlags", $UserFlags) $objUsr.SetInfo $ADS_PWChangeRight = @error else $ADS_PWChangeRight = @error endif endfunction
|
|
Top
|
|
|
|
#157399 - 2006-02-17 05:15 PM
Re: ADS_USER_FLAG --- How to manipulate the right to change password ?
|
Richard H.
Administrator
   
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
I meant bitwise AND (&) and not logical and of course.
Here is how you would do it: Code:
$ADS_UF_PASSWORD_CANT_CHANGE=&40 $NOT_ADS_UF_PASSWORD_CANT_CHANGE= ~$ADS_UF_PASSWORD_CANT_CHANGE $UserFlags = $UserFlags & $NOT_ADS_UF_PASSWORD_CANT_CHANGE
That first sentence reminds me of an old English joke:
How can you use the word "and" five time consecutively in a sentence and still make sense?
Answer in white below (highlight it if you can't see it):
A fish and chip shop owner is having a new sign made. He comes out of the shop and says to the sign-writer:
"The sign is no good. You have not left enough space between FISH and AND and AND and CHIPS."
|
|
Top
|
|
|
|
#157401 - 2006-02-19 08:16 AM
Re: ADS_USER_FLAG --- How to manipulate the right to change password ?
|
Howard Bullock
KiX Supporter
   
Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
|
You should not be using the Xor function with UserFlags bit setting.
To set a any bit: $UserFlags | $BitValue To clear any bit: $UserFlags & ~$BitValue.
All the bit value are listed on my site: http://home.comcast.net/~habullock/Win32Admin.htm#User
You can use the hex value or the decimal values.
|
|
Top
|
|
|
|
Moderator: Shawn, ShaneEP, Ruud van Velsen, Arend_, Jochen, Radimus, Glenn Barnas, Allen, Mart
|
0 registered
and 1183 anonymous users online.
|
|
|