| |
|
|
|
Description:
declared LsaAddAccountRights fügt one Account Privilegien hinzu. These function there only NT-based Windowssystemen. added Privilegien go naturally first to the renewed Einloggen the special Users active.
Deklaration:
DEF @LsaAddAccountRights(4) !advapi32,LsaAddAccountRights
Parameter:
1.Parameter: With the LSAOpenPolicy sustained lever the Policy Objektes as Longint. the lever must with POLICY_CREATE_ACCOUNT and POLICY_LOOKUP_NAMES opened go. 2.Parameter: Memory-Variable with the SID the Accounts, to the The Privilegien added should. 3.Parameter: Bereichvariable with a aray from LSA_UNICODE_STRING Structures, The indicated over The hinzuzufügenden Privilegien contains. => ·byte 0-1 = The long the Strings in Bytes, on the byte 4-7 verweist. ·byte 2-3 = The length the Bereichs in Bytes, on the byte 4-7 verweist. ·byte 4-7 = discretionary, but enough large Memory-Variable with a String in the Unicode stature, the whom names one hinzuzufügenden Privilegs contains. ·byte 8-9 = The long the Strings in Bytes, on the byte 12-15 verweist. ·byte 10-11 = The length the Bereichs in Bytes, on the byte 12-15 verweist. ·byte 12-15 = discretionary, but enough large Memory-Variable with a String in the Unicode stature, the whom names one hinzuzufügenden Privilegs contains. ·etc... 4.Parameter: The Number of hinzuzufügenden Privilegien from Parameter 3.
Return Value:
0 with success, otherwise one NT-status Error Code (LongInt), the with LsaNtStatusToWinError in a Systemfehlercode transformed go can.
Examples:
CompileMarkSeparationDEF @LsaOpenPolicy(4) !"advapi32","LsaOpenPolicy"
DEF @LsaClose(1) !"advapi32","LsaClose"
DEF @LsaNtStatusToWinError(1) !"advapi32","LsaNtStatusToWinError"
DEF @LsaAddAccountRights(4) !"advapi32","LsaAddAccountRights"
DEF @MultiByteToWideChar(6) !"kernel32","MultiByteToWideChar"
DEF @LookupAccountName(7) !"advapi32","LookupAccountNameA"
DEF @GetACP(0) !"kernel32","GetACP"
Declare Fehler&,UNICODE#,Attribut#,POLICY_Handle#
Declare Policy_Handle&,PrivilegSET#,PRIVILEG#
Declare SID#,DOMAIN#,SID_TYPE_INDICATOR#,DOMAIN#,Attribut#,ALLPRIVS#,COUNT#,SID#,DOMAINNAME_SIZE_ADDR#
Declare SYSTEM$,DOMAIN$,SID_Size#,Account$
Struct LSA_UNICODE_STRING=Length%,MaximumLength%,Buffer&
DIM UNICODE#,LSA_UNICODE_STRING
Clear UNICODE#
Struct LSA_OBJECT_ATTRIBUTES=Length&,RootDirectory&,Length%,MaximumLength%,Buffer&,Attributes&,SecurityDescriptor#(4),SecurityQualityOfService#(4)
DIM Attribut#,LSA_OBJECT_ATTRIBUTES
Clear Attribut#
DIM ALLPRIVS#,2000
DIM COUNT#,4
DIM DOMAIN#,256
DIM SID#,800
DIM SID_Size#,4
DIM DOMAINNAME_SIZE_ADDR#,4
DIM SID_TYPE_INDICATOR#,256
DIM POLICY_Handle#,4
DIM PRIVILEG#,100
DIM PrivilegSET#,100
Windowstyle 31
Windowtitle "Einem Account das Privileg zum Ändern der Systemzeit hinzufügen."
Window 0,0-640,440
CLEAR SID#,DOMAIN#,SID_TYPE_INDICATOR#,DOMAIN#,Attribut#,ALLPRIVS#,COUNT#,SID#,DOMAINNAME_SIZE_ADDR#
Long SID_Size#,0=800
LONG DOMAINNAME_SIZE_ADDR#,0=255
LET SYSTEM$=""
LET ACCOUNT$=@input$("Accountnamen eingeben (kein Alias):","Account","Gast")
LET Fehler&=@LookupAccountName(@ADDR(System$),@addr(ACCOUNT$),SID#,SID_Size#,DOMAIN#,DOMAINNAME_SIZE_ADDR#,SID_TYPE_INDICATOR#)
Print "Rückmeldung von LookupAccountName="+@STR$(Fehler&)
If Fehler&=1
LET Fehler&=@LsaOpenPolicy(0,Attribut#,$10 | $0800,POLICY_Handle#)
Print "Rückmeldung von LsaOpenPolicy="+@STR$(Fehler&)
Let Fehler&=@LsaNtStatusToWinError(Fehler&)
PRINT "LsaOpenPolicy Rückmeldung umgewandelt in Windows Fehlercode="+@STR$(Fehler&)
LET Policy_Handle&=@LONG(POLICY_Handle#,0)
Print "Geliefertes Handle="+@STR$(Policy_Handle&)
IF Fehler&=0
CLEAR UNICODE#,PrivilegSET#,PRIVILEG#
STRING PrivilegSET#,0="SeSystemtimePrivilege"
LET Fehler&=@MultiByteToWideChar(@GetACP(),0,PRIVILEGSET#,-1,PRIVILEG#,100)
Print "Rückmeldung von MultiByteToWideChar="+@STR$(Fehler&)
UNICODE#.Buffer&=PRIVILEG#
UNICODE#.Length%=@LEN("SeSystemtimePrivilege")*2
UNICODE#.MaximumLength%=100
LET Fehler&=@LsaAddAccountRights(Policy_Handle&,SID#,UNICODE#,1)
Print "Rückmeldung von LsaAddAccountRights="+@STR$(Fehler&)
Let Fehler&=@LsaNtStatusToWinError(Fehler&)
PRINT "LsaAddAccountRights Rückmeldung umgewandelt in Windows Fehlercode="+@STR$(Fehler&)
LET Fehler&=@LsaClose(Policy_Handle&,0)
Print "Rückmeldung von LsaClose="+@STR$(Fehler&)
Let Fehler&=@LsaNtStatusToWinError(Fehler&)
PRINT "LsaClose Rückmeldung umgewandelt in Windows Fehlercode="+@STR$(Fehler&)
Endif
endif
Dispose POLICY_Handle#
Dispose ALLPRIVS#
Dispose COUNT#
Dispose DOMAIN#
Dispose SID#
Dispose SID_Size#
Dispose DOMAINNAME_SIZE_ADDR#
Dispose SID_TYPE_INDICATOR#
Dispose POLICY_Handle#
Dispose PRIVILEG#
Dispose PrivilegSET#
While 0=0
nput
Wend
|
|
|
| |
|
|