Hallo,
ich möchte den Besitz von Dateien/Verzeichnissen übernehmen, auch wenn die Administratoren keinen expliziten Zugriff darauf haben. Dazu gibt es unter
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/security/security/taking_object_ownership_in_c__.asp
einen Beispiel-Code für C++.
Ich habe versucht diesen Code nach VB zu übersetzen. Leider bekomme ich in der Zeile 'dwRes = SetEntriesInAcl(NUM_ACES, ea, pOldDACL, pNewDACL)' den Fehler
Typen unverträglich.
Wer kann mir sagen warum?
Danke im vorraus
Hier der Code der Funktion
Private Function SetOwnership() As Boolean
Dim ea(NUM_ACES - 1) As EXPLICIT_ACCESS
Dim SIDAuthWorld As SID_IDENTIFIER_AUTHORITY
Dim SIDAuthNT As SID_IDENTIFIER_AUTHORITY
Dim pSIDAdmin As Long
Dim pSIDEveryone As Long
Dim pACL As Long
Dim pNewDACL As Long
Dim pOldDACL As Long
Dim dwRes As Long
SIDAuthWorld.Value(6) = SECURITY_WORLD_SID_AUTHORITY
SIDAuthNT.Value(6) = SECURITY_NT_AUTHORITY
' Specify the DACL to use.
' Create a SID for the Everyone group.
dwRes& = AllocateAndInitializeSid(SIDAuthWorld, 1, SECURITY_WORLD_RID, 0, _
0, 0, 0, 0, 0, 0, pSIDEveryone)
If dwRes& = 0 Then
MsgBox "AllocateAndInitializeSid (Everyone) error (" & dwRes& & "):" & _
dwRes&
GoTo Cleanup
End If
' Create a SID for the BUILTIN\Administrators group.
dwRes& = AllocateAndInitializeSid(SIDAuthNT, 2, _
SECURITY_BUILTIN_DOMAIN_RID, DOMAIN_ALIAS_RID_ADMINS, _
0, 0, 0, 0, 0, 0, pSIDAdmin)
If dwRes& = 0 Then
MsgBox "AllocateAndInitializeSid (Admin) error (" & dwRes& & "):" & _
dwRes&
GoTo Cleanup
End If
' Set read access for Everyone.
ea(0).grfAccessPermissions = GENERIC_READ
ea(0).grfAccessMode = SET_ACCESS
ea(0).grfInheritance = NO_INHERITANCE
ea(0).pTRUSTEE.TrusteeForm = TRUSTEE_IS_SID
ea(0).pTRUSTEE.TrusteeType = TRUSTEE_IS_WELL_KNOWN_GROUP
ea(0).pTRUSTEE.ptstrName = pSIDEveryone
' Set full control for Administrators.
ea(1).grfAccessPermissions = GENERIC_ALL
ea(1).grfAccessMode = SET_ACCESS
ea(1).grfInheritance = NO_INHERITANCE
ea(1).pTRUSTEE.TrusteeForm = TRUSTEE_IS_SID
ea(1).pTRUSTEE.TrusteeType = TRUSTEE_IS_GROUP
ea(1).pTRUSTEE.ptstrName = pSIDAdmin
' SetEntriesInAcl() API
dwRes = SetEntriesInAcl(NUM_ACES, ea, pOldDACL, pNewDACL)
If dwRes& <> ERROR_SUCCESS Then
MsgBox "Failed SetEntriesInAcl error (" & dwRes& & "):" & dwRes&
GoTo Cleanup
End If
.....
....
End Function |