PsaltyDS Posted August 15, 2006 Share Posted August 15, 2006 (edited) Posted this in v3 Support and got only cricket chirping in reply... I never hit the easy way to do anything on the first try, so was hoping to get helpfull critique of this function, and what I missed. The function is called _UserCtrlAttribs() and it reads, sets, and clears bits in the UserFlags attribute of a user (either local or domain). The constants at the begining of the test script give the basic attributes that can be set or cleared. The ones I needed immediately are the ones labeled "User cannot change password", and "Password never expires" in the GUI user managers, but it will handle any flag defined by ADS_USER_FLAG_ENUM. (keeping in mind some of them are read-only.) There are more than I give here, but they get pretty esoteric.The only required parameter is the user name, which can be plain, or combined with a context. Without further options, it just returns the UserFlags data word for the user:$RetVal_1 = _UserCtrlAttribs("MyUser_1") ; returns attributes of user "MyUser_1" $RetVal_2 = _UserCtrlAttribs("MyDomain\MyUser_2") ; returns attributes of user "MyUser_2" in domain "MyDomain"oÝ÷ Ù8^±ç(ÚZ©µêâ²mÚ©Ý+Þ²Ø^iËb¢{h¥êߢ¹·½©bu§-ìj·yø§yÚ®¢Ô^iÚ®¢Ûay×jémªê-IëjºZÚ®¢Ð¥yªêºSç^}«¥¶«¨µv«¨µ§-ãºËkzÛ«ËayË«éí½©nzÔ±êŨ,ªê-IëjºmjG¬y§!n+lzا¶*Ý¥ªÚë^¯br¬Ñ¼yö®Ö§vDzØ^rëzÊhا¸{azë¯lRÇ«V ±8^ªê- W®«¨µ§-ðYmjGiÈ[Û¶)íëa·ij¶¦z׫jw櫶¢ºÞ²'v)àRÇ«V ±¸jëh×6$RetVal_1 = _UserCtrlAttribs("MyUser_1", "Set", $USER_NOEXPIREPASSWD) ; Sets "Password never expires on MyUser_1 $RetVal_2 = _UserCtrlAttribs("MyUser_2", "Clear", $USER_ACCOUNTDISABLE) ; Clears the bit for "Account disabled" on MyUser_2oÝ÷ Øù^jÇ¥zÙz0ò&ËvØ^y«"z¼ÊÚ¢Øb±:+º{az׬¶Ç+cºËæy©hq©n±êêºSzËT±êêºZÚîØ^±Êâ¦ÔázÇ+pYky§Z×b²ZÊØ^RÇ«V ³ +uú+¶ºÇ«¶§±ëm涸º×¬~êºT±êÜjyèµÈZ©jË0¢·jºZÚ®¢ÓÚ²Ì(ÙÞ½êÞÆ«zÊ®¢Ö§vØ^·vËay«m®&îµë¨§¶Þ®'ò¶Û0z·¬zÖ®¶sc²FW7BöbõW6W$7G&ÄGG&'2£²BVwW7BÂ#bÒ'6ÇGE2BGG¢ò÷wwræWFöG67&Bæ6öÒöf÷'VÐ £²6öç7FçG2FW&fVBg&öÓ £²GG¢òö×6FâæÖ7&÷6ögBæ6öÒöÆ'&'öFVfVÇBâââç%öfÆuöVçVÒæ7¤FÒ6öç7Bb33cµU4U%õ%Tå45$BÒ²W6W"'Vç2Æövöâ67&Bà¤FÒ6öç7Bb33cµU4U%ô44õTåDD4$ÄRÒ"²W6W"66÷VçBF6&ÆVBà¤FÒ6öç7Bb33cµU4U%ôÄô4´õUBÒ²66÷VçB2Æö6¶VB÷WBà¤FÒ6öç7Bb33cµU4U%ôäõ55tBÒ#²æò77v÷&B&WV&VBà¤FÒ6öç7Bb33cµU4U%ôäô4ätU55tBÒC²W6W"6ææ÷B6ævR77v÷&Bà¤FÒ6öç7Bb33cµU4U%ôäõ$ÔÄ44õTåBÒ#²FVfVÇB66÷VçBGRöbæ÷&ÖÂW6W"à¤FÒ6öç7Bb33cµU4U%ôäôU$U55tBÒ²77v÷&BvÆÂæ÷BW&Rà¤FÒ6öç7Bb33cµU4U%õ4Ô%D4$E$UT$TBÒC²f÷&6RW6W"FòÆöröâW6ær6Ö'B6&Bà¤FÒ6öç7Bb33cµU4U%õ55tõ$DU$TBÒ²77v÷&B2W&VBà £²FV6Æ&R4ôÒö&¦V7BW'&÷"æFÆW# ¤vÆö&Âb33c¶ô6öÔW'&÷"Òö&¤WfVçBgV÷C´WFôBäW'&÷"gV÷C²ÂgV÷Cµô6öÔW'$gVæ2gV÷C² ¢b33cµG7EW7"ÒgV÷CµFW7BW6W"gV÷C²²W6W"Fòv÷&²öà ¢b33cµ&W7VÇBÒõW6W$7G&ÄGG&'2b33cµG7EW7"¤×6t&÷cBÂgV÷Cµ&W7VÇG2gV÷C²ÂgV÷C´æFÂW6W$fÆw2vW&S¢gV÷C²fײWb33cµ&W7VÇBfײ5$Äbfײð¢gV÷C´W'&÷"ÒgV÷C²fײW'&÷" ¢b33c´æWt&G2Ò&Dõ"b33cµU4U%ôäô4ätU55tBÂb33cµU4U%ôäôU$U55tB¢b33cµ&W7VÇBÒõW6W$7G&ÄGG&'2b33cµG7EW7"ÂgV÷Cµ6WBgV÷C²Âb33c´æWt&G2¤×6t&÷cBÂgV÷Cµ&W7VÇG2gV÷C²ÂgV÷Cµ&WGW&âg&öÒ6ævRv3¢gV÷C²fײWb33cµ&W7VÇBfײ5$Äbfײð¢gV÷C´W'&÷"ÒgV÷C²fײW'&÷" ¢b33cµ&W7VÇBÒõW6W$7G&ÄGG&'2b33cµG7EW7"¤×6t&÷cBÂgV÷Cµ&W7VÇG2gV÷C²ÂgV÷C´fæÂW6W$fÆw2&S¢gV÷C²fײWb33cµ&W7VÇBfײ5$Äbfײð¢gV÷C´W'&÷"ÒgV÷C²fײW'&÷" £²ÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒУ²gVæ7FöâõW6W$7G&ÄGG&'2£²6öçG&öÂGG&'WFR&G2öâW6W"66÷VçBâFRW6W$fÆw2v÷&@£²6ÆÂvF¢õW6W$7G&ÄGG&'2b33c·5W7$æÖRÂb33c·4ÖöFRÒgV÷C´vWBgV÷C²Âb33c¶GG&'2ÒvW&S £²b33c·5W7$æÖRÒW6W$æÖRFò6WBGG&'WFRöࣲb33c·4ÖöFRÒ7FöâFòF¶S £²gV÷C´vWBgV÷C²FVfVÇBÒ&VBFR7W'&VçBW6W$fÆw2v÷&BvF÷WB6ævær@£²gV÷Cµ6WBgV÷C²Ò6WB&BâW6W$fÆw2f÷"V6&B6WBâb33c¶GG&'0£²gV÷C´6ÆV"gV÷C²Ò6ÆV"&BâW6W$fÆw2f÷"V6&B6WBâb33c¶GG&'0£²b33c¶GG&'2ÒGG&'WFR&G2Fò6W@£°£²öâ7V66W73¢&WGW&ç2FR&W7VÇFærW6W"66÷VçBGG&'WFW2fÆw2ࣲöâfÇW&S¢W'&÷"Ò6÷VÆBæ÷B6öææV7BFòW6W"ö&¦V7@£²W'&÷"Ò"çfÆBÖöFR6VÆV7FV@£°£²æ÷FS¢bFR6öçFWB2æ÷BvfVâf÷"W6W"÷"w&÷WÂæRâf÷&ÖB2gV÷CµW6W$æÖRgV÷C²À£²FVâÆö6Â6ö×WFW"6öçFWBvÆÂ&R77VÖVBâFöÖâ÷"&VÖ÷FR6ö×WFW"6öçFW@£²6â&R&÷fFVB'f÷&ÖGFærW6W"÷"w&÷W2gV÷C´6öçFWBõW6W$æÖRgV÷C²à£²ÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒФgVæ2õW6W$7G&ÄGG&'2b33c·5W7$æÖRÂb33c·4ÖöFRÒgV÷C´vWBgV÷C²Âb33c¶GG&'2Ò¢Æö6Âb33c¶&WGW&âÒÂb33c¶W'&÷'2Ò¢¢²f÷&ÖBW6W"f÷"Æö6Âb6öçFWBæ÷BvfVà¢Æö6Âb33c¶W6W%7ÆBÒ7G&æu7ÆBb33c·5W7$æÖRÂgV÷C²b3#²ògV÷C²Â¢bb33c¶W6W%7ÆE³ÒÒFVà¢b33c·5W7$æÖRÒ6ö×WFW$æÖRfײgV÷C²ògV÷C²fײb33c·5W7$æÖP¢VÇ6P¢b33c·5W7$æÖRÒ7G&æu&WÆ6Rb33c·5W7$æÖRÂgV÷C²b3#²gV÷C²ÂgV÷C²ògV÷C²¢VæD`¢¢²æBW6W"4ôÒö&¦V7@¢Æö6Âb33c¶ö&¥W6W"Òö&¤vWBgV÷CµväåC¢òògV÷C²fײb33c·5W7$æÖRfײgV÷C²ÂW6W"gV÷C²¢bW'&÷"÷"æ÷B4ö&¢b33c¶ö&¥W6W"FVâ&WGW&â6WDW'&÷"ÂÂÓ¢¢²vWB7W'&VçBGG&'WFW0¢b33c¶7W'$GG&"Òb33c¶ö&¥W6W"ævWBgV÷CµW6W$fÆw2gV÷C²¢bW'&÷"FVâb33c¶W'&÷'2³Ò¢¢7vF6b33c·4ÖöFP¢66RgV÷C´vWBgV÷C°¢²&WGW&âW6W$fÆw0¢b33c¶&WGW&âÒb33c¶7W'$GG& ¢¢66RgV÷Cµ6WBgV÷C°¢²6WB&÷W'FW2f÷"W6W ¢b33c¶&WGW&âÒ&Dõ"b33c¶7W'$GG&"Âb33c¶GG&'2¢b33c¶ö&¥W6W"åWBgV÷CµW6W$fÆw2gV÷C²Âb33c¶&WGW&â¢bW'&÷"FVâb33c¶W'&÷'2³Ò¢b33c¶ö&¥W6W"å6WDæfð¢bW'&÷"FVâb33c¶W'&÷'2³Ò¢¢66RgV÷C´6ÆV"gV÷C°¢²6ÆV"&÷W'FW2f÷"W6W ¢b33c¶&WGW&âÒ&DäBb33c¶7W'$GG&"Â&DäõBb33c¶GG&'2¢b33c¶ö&¥W6W"åWBgV÷CµW6W$fÆw2gV÷C²Âb33c¶&WGW&â¢bW'&÷"FVâb33c¶W'&÷'2³Ò¢b33c¶ö&¥W6W"å6WDæfð¢bW'&÷"FVâb33c¶W'&÷'2³Ò¢¢66RVÇ6P¢²çfÆBb33c·4ÖöFR6ÆÆV@¢&WGW&â6WDW'&÷""ÂÂÓ¢VæE7vF6¢¢²&WGW&â&W7VÇG0¢bb33c¶W'&÷'2ÒFVà¢&WGW&âb33c¶&WGW&à¢VÇ6P¢&WGW&â6WDW'&÷"¢VæD`¤VæDgVæ2³ÓÒfwCµõW6W$7G&ÄGG&'0 £²ÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒУ²gVæ7Föâô6öÔW'$gVæ2£²7W7FöÒ4ôÒö&¦V7BW'&÷"æFÆW £²ÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒÒФgVæ2ô6öÔW'$gVæ2¢Æö6Âb33c´WçVÖ&W"ÒWb33c¶ô6öÔW'&÷"æçVÖ&W"¢×6t&÷bÂgV÷C´4ôÒU%$õ"b333²gV÷C²ÂgV÷C´WFôB4ôÒW'&÷"ö67W&VBb333²gV÷C²fײ5$Äbfײð¢D"fײgV÷C´W'&÷"çVÖ&W#¢gV÷C²fײb33c´WçVÖ&W"fײ5$Äbfײð¢D"fײgV÷C´ÆæRçVÖ&W#¢gV÷C²fײb33c¶ô6öÔW'&÷"ç67&FÆæRfײ5$Äbfײð¢D"fײgV÷C´FW67&Föã¢gV÷C²fײb33c¶ô6öÔW'&÷"æFW67&Föâfײ5$Äbfײð¢D"fײgV÷CµväFW67&Föã¢gV÷C²fײb33c¶ô6öÔW'&÷"çvæFW67&Föâ¢6WDW'&÷"²6öÖWFærFò6V6²f÷"vVâF2gVæ7Föâ&WGW&ç0¤VæDgVæ2³ÓÒfwCµô6öÔW'$gVæ0 Edited August 15, 2006 by PsaltyDS Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
PsaltyDS Posted August 15, 2006 Author Share Posted August 15, 2006 Updated the demo script to ask for the account, and have tested now on Windows 2003 server, with both local and AD domain accounts. So far, so good. The test now sets the following bits: $USER_ACCOUNTDISABLE, $USER_NOCHANGEPASSWD, and $USER_NOEXPIREPASSWD It then clears the bits for $USER_NOCHANGEPASSWD and $USER_NOEXPIREPASSWD, leaving the account disabled. Would still like to know if anyone sees something not working or easier some other way... expandcollapse popup; Test of _UserCtrlAttribs() ; 15 August, 2006 - By PsaltyDS at http://www.autoitscript.com/forum ; Constants derived from: ; http://msdn.microsoft.com/library/default.asp?url=/library/en-us/adsi/adsi/ads_user_flag_enum.asp ; ===== General Account Flags ===== Dim Const $USER_RUNSCRIPT = 0x1 ; User runs logon script. Dim Const $USER_ACCOUNTDISABLE = 0x2 ; User account disabled. Dim Const $USER_LOCKOUT = 0x10 ; Account is locked out. Dim Const $USER_NOPASSWD = 0x20 ; No password required. Dim Const $USER_NOCHANGEPASSWD = 0x40 ; User cannot change password. Dim Const $USER_NORMALACCOUNT = 0x200 ; Default account type of a normal user. Dim Const $USER_NOEXPIREPASSWD = 0x10000 ; Password will not expire. Dim Const $USER_SMARTCARDREQUIRED = 0x40000 ; Force user to log on using a smart card. Dim Const $USER_PASSWORDEXPIRED = 0x800000 ; Password has expired. ; Declare COM Object error handler: Global $oComError = ObjEvent("AutoIt.Error", "_ComErrFunc") $TstUsr = InputBox("_UserCtrlAttribs() Demo", "Input user name to change: ", "") ; Get user to work on If $TstUsr = "" Then Exit $Result = _UserCtrlAttribs($TstUsr) MsgBox(64, "Results", "Initial UserFlags were: " & Hex($Result) & @CRLF & _ "@Error = " & @error) $NewBits = BitOR($USER_NOCHANGEPASSWD, $USER_NOEXPIREPASSWD, $USER_ACCOUNTDISABLE) $Result = _UserCtrlAttribs($TstUsr, "Set", $NewBits) $Result = _UserCtrlAttribs($TstUsr) MsgBox(64, "Results", "UserFlags after setting bits are: " & Hex($Result) & @CRLF & _ "@Error = " & @error) $NewBits = BitOR($USER_NOCHANGEPASSWD, $USER_NOEXPIREPASSWD) $Result = _UserCtrlAttribs($TstUsr, "Clear", $NewBits) $Result = _UserCtrlAttribs($TstUsr) MsgBox(64, "Results", "UserFlags after clearing bits are: " & Hex($Result) & @CRLF & _ "@Error = " & @error) ;-------------------------------------- ; Function _UserCtrlAttribs() ; Control attribute bits on a user account in the UserFlags word ; Call with: _UserCtrlAttribs($sUsrName, $sMode = "Get", $iAttribs = 0) where: ; $sUsrName = UserName to set attribute on ; $sMode = Action to take: ; "Get" (default) = Read the current UserFlags word without changing it ; "Set" = Set bit in UserFlags for each bit set in $iAttribs ; "Clear" = Clear bit in UserFlags for each bit set in $iAttribs ; $iAttribs = Attribute bits to set ; ; On success: Returns the resulting user account attributes flags. ; On failure: @error = 1 could not connect to user object ; @error = 2 invalid mode selected ; ; Note: If the context is not given for user or group, i.e. format is "UserName", ; then local computer context will be assumed. Domain or remote computer context ; can be provided by formatting user or group as "Context/UserName". ;-------------------------------------- Func _UserCtrlAttribs($sUsrName, $sMode = "Get", $iAttribs = 0) Local $iReturn = 0, $iErrors = 0 ; Format user for local if context not given Local $aUserSplit = StringSplit($sUsrName, "\/", 0) If $aUserSplit[0] = 1 Then $sUsrName = @ComputerName & "/" & $sUsrName Else $sUsrName = StringReplace($sUsrName, "\", "/") EndIf ; Init user COM object Local $objUser = ObjGet("WinNT://" & $sUsrName & ", User") If @error Or Not IsObj($objUser) Then Return SetError(1, 0, -1) ; Get current attributes $iCurrAttrib = $objUser.get ("UserFlags") If @error Then $iErrors += 1 Switch $sMode Case "Get" ; Return UserFlags $iReturn = $iCurrAttrib Case "Set" ; Set properties for user $iReturn = BitOR($iCurrAttrib, $iAttribs) $objUser.Put ("UserFlags", $iReturn) If @error Then $iErrors += 1 $objUser.SetInfo If @error Then $iErrors += 1 Case "Clear" ; Clear properties for user $iReturn = BitAND($iCurrAttrib, BitNOT($iAttribs)) $objUser.Put ("UserFlags", $iReturn) If @error Then $iErrors += 1 $objUser.SetInfo If @error Then $iErrors += 1 Case Else ; Invalid $sMode called Return SetError(2, 0, -1) EndSwitch ; Return results If $iErrors = 0 Then Return $iReturn Else Return SetError(1, 0, 0) EndIf EndFunc ;==>_UserCtrlAttribs ;-------------------------------------- ; Function _ComErrFunc() ; Custom COM object error handler ;-------------------------------------- Func _ComErrFunc() Local $HexNumber = Hex($oComError.number, 8) MsgBox(16, "COM ERROR!", "AutoIT COM Error Occured!" & @CRLF & _ @TAB & "Error Number: " & $HexNumber & @CRLF & _ @TAB & "Line Number: " & $oComError.scriptline & @CRLF & _ @TAB & "Description: " & $oComError.description & @CRLF & _ @TAB & "WinDescription: " & $oComError.windescription) SetError(1); something to check for when this function returns EndFunc ;==>_ComErrFunc Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
EndFunc Posted February 21, 2009 Share Posted February 21, 2009 (edited) Updated the demo script to ask for the account, and have tested now on Windows 2003 server, with both local and AD domain accounts. So far, so good. The test now sets the following bits: $USER_ACCOUNTDISABLE, $USER_NOCHANGEPASSWD, and $USER_NOEXPIREPASSWD It then clears the bits for $USER_NOCHANGEPASSWD and $USER_NOEXPIREPASSWD, leaving the account disabled. Would still like to know if anyone sees something not working or easier some other way... expandcollapse popup; Test of _UserCtrlAttribs() ; 15 August, 2006 - By PsaltyDS at http://www.autoitscript.com/forum ; Constants derived from: ; http://msdn.microsoft.com/library/default.asp?url=/library/en-us/adsi/adsi/ads_user_flag_enum.asp ; ===== General Account Flags ===== Dim Const $USER_RUNSCRIPT = 0x1 ; User runs logon script. Dim Const $USER_ACCOUNTDISABLE = 0x2 ; User account disabled. Dim Const $USER_LOCKOUT = 0x10 ; Account is locked out. Dim Const $USER_NOPASSWD = 0x20 ; No password required. Dim Const $USER_NOCHANGEPASSWD = 0x40 ; User cannot change password. Dim Const $USER_NORMALACCOUNT = 0x200 ; Default account type of a normal user. Dim Const $USER_NOEXPIREPASSWD = 0x10000 ; Password will not expire. Dim Const $USER_SMARTCARDREQUIRED = 0x40000 ; Force user to log on using a smart card. Dim Const $USER_PASSWORDEXPIRED = 0x800000 ; Password has expired. ; Declare COM Object error handler: Global $oComError = ObjEvent("AutoIt.Error", "_ComErrFunc") $TstUsr = InputBox("_UserCtrlAttribs() Demo", "Input user name to change: ", "") ; Get user to work on If $TstUsr = "" Then Exit $Result = _UserCtrlAttribs($TstUsr) MsgBox(64, "Results", "Initial UserFlags were: " & Hex($Result) & @CRLF & _ "@Error = " & @error) $NewBits = BitOR($USER_NOCHANGEPASSWD, $USER_NOEXPIREPASSWD, $USER_ACCOUNTDISABLE) $Result = _UserCtrlAttribs($TstUsr, "Set", $NewBits) $Result = _UserCtrlAttribs($TstUsr) MsgBox(64, "Results", "UserFlags after setting bits are: " & Hex($Result) & @CRLF & _ "@Error = " & @error) $NewBits = BitOR($USER_NOCHANGEPASSWD, $USER_NOEXPIREPASSWD) $Result = _UserCtrlAttribs($TstUsr, "Clear", $NewBits) $Result = _UserCtrlAttribs($TstUsr) MsgBox(64, "Results", "UserFlags after clearing bits are: " & Hex($Result) & @CRLF & _ "@Error = " & @error) ;-------------------------------------- ; Function _UserCtrlAttribs() ; Control attribute bits on a user account in the UserFlags word ; Call with: _UserCtrlAttribs($sUsrName, $sMode = "Get", $iAttribs = 0) where: ; $sUsrName = UserName to set attribute on ; $sMode = Action to take: ; "Get" (default) = Read the current UserFlags word without changing it ; "Set" = Set bit in UserFlags for each bit set in $iAttribs ; "Clear" = Clear bit in UserFlags for each bit set in $iAttribs ; $iAttribs = Attribute bits to set ; ; On success: Returns the resulting user account attributes flags. ; On failure: @error = 1 could not connect to user object ; @error = 2 invalid mode selected ; ; Note: If the context is not given for user or group, i.e. format is "UserName", ; then local computer context will be assumed. Domain or remote computer context ; can be provided by formatting user or group as "Context/UserName". ;-------------------------------------- Func _UserCtrlAttribs($sUsrName, $sMode = "Get", $iAttribs = 0) Local $iReturn = 0, $iErrors = 0 ; Format user for local if context not given Local $aUserSplit = StringSplit($sUsrName, "\/", 0) If $aUserSplit[0] = 1 Then $sUsrName = @ComputerName & "/" & $sUsrName Else $sUsrName = StringReplace($sUsrName, "\", "/") EndIf ; Init user COM object Local $objUser = ObjGet("WinNT://" & $sUsrName & ", User") If @error Or Not IsObj($objUser) Then Return SetError(1, 0, -1) ; Get current attributes $iCurrAttrib = $objUser.get ("UserFlags") If @error Then $iErrors += 1 Switch $sMode Case "Get" ; Return UserFlags $iReturn = $iCurrAttrib Case "Set" ; Set properties for user $iReturn = BitOR($iCurrAttrib, $iAttribs) $objUser.Put ("UserFlags", $iReturn) If @error Then $iErrors += 1 $objUser.SetInfo If @error Then $iErrors += 1 Case "Clear" ; Clear properties for user $iReturn = BitAND($iCurrAttrib, BitNOT($iAttribs)) $objUser.Put ("UserFlags", $iReturn) If @error Then $iErrors += 1 $objUser.SetInfo If @error Then $iErrors += 1 Case Else ; Invalid $sMode called Return SetError(2, 0, -1) EndSwitch ; Return results If $iErrors = 0 Then Return $iReturn Else Return SetError(1, 0, 0) EndIf EndFunc ;==>_UserCtrlAttribs ;-------------------------------------- ; Function _ComErrFunc() ; Custom COM object error handler ;-------------------------------------- Func _ComErrFunc() Local $HexNumber = Hex($oComError.number, 8) MsgBox(16, "COM ERROR!", "AutoIT COM Error Occured!" & @CRLF & _ @TAB & "Error Number: " & $HexNumber & @CRLF & _ @TAB & "Line Number: " & $oComError.scriptline & @CRLF & _ @TAB & "Description: " & $oComError.description & @CRLF & _ @TAB & "WinDescription: " & $oComError.windescription) SetError(1); something to check for when this function returns EndFunc ;==>_ComErrFuncThis looks very good. I wonder why there is no response to this. this is well needed and should be in the adfunctions udf. Very nice Edited February 21, 2009 by EndFunc EndFuncAutoIt is the shiznit. I love it. Link to comment Share on other sites More sharing options...
PsaltyDS Posted February 21, 2009 Author Share Posted February 21, 2009 This looks very good. I wonder why there is no response to this. this is well needed and should be in the adfunctions udf. Very niceThanks, but this was written for compatibility with WMI only, not LDAP paths or user AD objects as inputs, so it might not be a good fit for the AD functions UDF (at least it would need modification). Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
EndFunc Posted February 23, 2009 Share Posted February 23, 2009 Thanks, but this was written for compatibility with WMI only, not LDAP paths or user AD objects as inputs, so it might not be a good fit for the AD functions UDF (at least it would need modification). Would this be hard to make it work with User AD objects or LDAP paths? This would be awesome if it did. I've been looking for something like this to see about objects like folders on a share etc. Does this not do this? I'm just not skilled enough to mod it or I would. EndFuncAutoIt is the shiznit. I love it. Link to comment Share on other sites More sharing options...
LoWang Posted April 20, 2009 Share Posted April 20, 2009 (edited) nice! Thanks a lot. I have a lame question yet: what is the purpose of Global $oComError = ObjEvent("AutoIt.Error", "_ComErrFunc") ? Aha I see it can handle some com errors. In which case can this happen? Edited April 20, 2009 by LoWang Link to comment Share on other sites More sharing options...
spudw2k Posted April 20, 2009 Share Posted April 20, 2009 ...what is the purpose of Global $oComError = ObjEvent("AutoIt.Error", "_ComErrFunc") ? Aha I see it can handle some com errors. In which case can this happen?Errors that I've run into are (not stated verbatim here):unable to connectaccess deniedno such property or method Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX BuilderMisc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retreive SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose ArrayProjects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalcCool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now