forked from Pahiro/AutoIT-Scripts
-
Notifications
You must be signed in to change notification settings - Fork 2
/
BulkPassChange.au3
69 lines (61 loc) · 2.12 KB
/
BulkPassChange.au3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#cs
Author: Bennet van der Gryp
Description: Password change program to keep all SAP systems in synch.
#ce
Global $LogonControl = ObjCreate("SAP.LogonControl.1")
Global $FuncControl = ObjCreate("SAP.Functions")
Global $objFileSystemObject = ObjCreate("Scripting.FileSystemObject")
$nr = 0
$string = ""
$var = ""
$newpass = InputBox("New","Enter new password")
While 1
$nr += 1
$sys = IniRead("changepass.ini", "SYS", "Item" & $nr, "")
$app = IniRead("changepass.ini", "APP", "Item" & $nr, "")
$sysnr = IniRead("changepass.ini", "SYSNR", "Item" & $nr, "")
$client = IniRead("changepass.ini", "CLIENT", "Item" & $nr, "")
$lang = IniRead("changepass.ini", "LANG", "Item" & $nr, "")
$currpass = IniRead("changepass.ini", "PASS", "Item" & $nr, "")
$newpass = $newpass
If $sys = "" Then
ExitLoop
Else
$Return = ChangePassword($sys, $app, $sysnr, $client, $lang, $currpass, $newpass)
If $Return = "Success" Then
IniWrite("changepass.ini","PASS", "Item" & $nr, $newpass)
ConsoleWrite($sys & $client & " : Password changed to " & $newpass & @CRLF)
Else
ConsoleWrite($sys & $client & " : Password change failed" & @CRLF)
EndIf
EndIf
WEnd
Func ChangePassword(ByRef $sys, ByRef $app, ByRef $sysnr, ByRef $client, ByRef $lang, ByRef $currpass, ByRef $newpass)
$oConnection = $LogonControl.NewConnection
$oConnection.System = $sys
$oConnection.ApplicationServer = $app
$oConnection.SystemNumber = $sysnr
$oConnection.Client = $client
$oConnection.Language = $lang
$oConnection.user = "A159994"
$oConnection.Password = $currpass
$LoggedIn = $oConnection.Logon (0,True)
If $LoggedIn = True Then
$FuncControl.connection = $oConnection
$CHPASS_FN = $FuncControl.Add("SUSR_USER_CHANGE_PASSWORD_RFC")
$expPassword = $CHPASS_FN.Exports("PASSWORD")
$expNewPass = $CHPASS_FN.Exports("NEW_PASSWORD")
$expFillRet = $CHPASS_FN.Exports("USE_BAPI_RETURN")
$impReturn = $CHPASS_FN.Imports("RETURN")
$expPassword.Value = $currpass
$expNewPass.Value = $newpass
$expFillRet.Value = "1"
If $CHPASS_FN.Call = True Then
Return "Success"
Else
Return "False"
EndIf
Else
Return "False"
EndIf
EndFunc