Esempio n. 1
0
		public static extern BOOL GetSecurityDescriptorOwner(
			PSECURITY_DESCRIPTOR pSecurityDescriptor, 
			out PSID pOwner, 
			out BOOL lpbOwnerDefaulted
			);
Esempio n. 2
0
		public static extern BOOL GetSecurityDescriptorGroup(
			PSECURITY_DESCRIPTOR pSecurityDescriptor, 
			out PSID pGroup, 
			out BOOL lpbGroupDefaulted
			);
Esempio n. 3
0
		public static extern DWORD GetSecurityDescriptorLength(
			PSECURITY_DESCRIPTOR pSecurityDescriptor
			);
Esempio n. 4
0
		public static extern BOOL InitializeSecurityDescriptor(PSECURITY_DESCRIPTOR pSecurityDescriptor, DWORD dwRevision);
Esempio n. 5
0
		public static extern BOOL GetSecurityDescriptorControl(
			PSECURITY_DESCRIPTOR pSecurityDescriptor, 
			out SECURITY_DESCRIPTOR_CONTROL pControl, 
			out DWORD lpdwRevision
			);
Esempio n. 6
0
        /// <summary>
        /// Gets the effective permissions for the provided Sid within the Security Descriptor.
        /// </summary>
        /// <param name="pUserSid">A pointer to the Sid of the identity to check.</param>
        /// <param name="serverName">Name of the server. This can be <c>null</c>.</param>
        /// <param name="pSecurityDescriptor">A pointer to the security descriptor.</param>
        /// <returns>An array of access masks.</returns>
        public virtual uint[] GetEffectivePermission(PSID pUserSid, string serverName, PSECURITY_DESCRIPTOR pSecurityDescriptor)
        {
            var mask = pUserSid.GetEffectiveRights(pSecurityDescriptor);

            return(new[] { mask });
        }
Esempio n. 7
0
 /// <summary>
 /// Gets the effective permissions for the provided Sid within the Security Descriptor.
 /// Called only when an object type identifier is specified.
 /// </summary>
 /// <param name="objTypeId">The object type identifier.</param>
 /// <param name="pUserSid">A pointer to the Sid of the identity to check.</param>
 /// <param name="serverName">Name of the server. This can be <c>null</c>.</param>
 /// <param name="pSecurityDescriptor">A pointer to the security descriptor.</param>
 /// <param name="objectTypeList">The object type list.</param>
 /// <param name="grantedAccessList">An array of access masks.</param>
 /// <returns></returns>
 /// <exception cref="System.NotImplementedException"></exception>
 public virtual HRESULT GetEffectivePermission(Guid objTypeId, PSID pUserSid, string serverName, PSECURITY_DESCRIPTOR pSecurityDescriptor, out OBJECT_TYPE_LIST[] objectTypeList, out uint[] grantedAccessList)
 {
     objectTypeList    = null;
     grantedAccessList = null;
     return(HRESULT.E_NOTIMPL);
 }
Esempio n. 8
0
 public static string ConvertSecurityDescriptorToStringSecurityDescriptor(PSECURITY_DESCRIPTOR SecurityDescriptor, SECURITY_INFORMATION SecurityInformation) =>
 ConvertSecurityDescriptorToStringSecurityDescriptor(SecurityDescriptor, SDDL_REVISION.SDDL_REVISION_1, SecurityInformation, out var sd, out var sz) ? sd.ToString(-1) : throw new Win32Exception();
Esempio n. 9
0
 public static extern bool ConvertSecurityDescriptorToStringSecurityDescriptor(PSECURITY_DESCRIPTOR SecurityDescriptor, SDDL_REVISION RequestedStringSDRevision,
                                                                               SECURITY_INFORMATION SecurityInformation, out SafeLocalHandle StringSecurityDescriptor, out uint StringSecurityDescriptorLen);
 internal static extern DWORD GetSecurityInfo(
     SafeFileHandle handle,
     ObjectType objectType,
     SecurityInformationClass infoClass,
     PSID owner,
     PSID group,
     PACL dacl,
     PACL sacl,
     out PSECURITY_DESCRIPTOR securityDescriptor);
Esempio n. 11
0
 /// <summary>Converts a PSECURITY_DESCRIPTOR to a managed RawSecurityDescriptor.</summary>
 /// <param name="securityDescriptor">The security descriptor.</param>
 /// <returns>The RawSecurityDescriptor.</returns>
 public static RawSecurityDescriptor ToManaged(this PSECURITY_DESCRIPTOR securityDescriptor) => new RawSecurityDescriptor(securityDescriptor.ToByteArray(), 0);
 internal static extern bool AuthzAccessCheck(
     AuthzACFlags flags,
     AUTHZ_CLIENT_CONTEXT_HANDLE hAuthzClientContext,
     ref AUTHZ_ACCESS_REQUEST pRequest,
     AUTHZ_AUDIT_EVENT_HANDLE AuditEvent,
     byte[] rawSecurityDescriptor,
     PSECURITY_DESCRIPTOR[] OptionalSecurityDescriptorArray,
     DWORD OptionalSecurityDescriptorCount,
     ref AUTHZ_ACCESS_REPLY pReply,
     AUTHZ_ACCESS_CHECK_RESULTS_HANDLE cachedResults);
Esempio n. 13
0
 public static extern BOOL SetUserObjectSecurity(
     HANDLE hObj,
     SECURITY_INFORMATION SecurityInformation,
     PSECURITY_DESCRIPTOR SecurityDescriptor
     );
Esempio n. 14
0
        public static byte[] ConvertSecurityDescriptorToByteArray(PSECURITY_DESCRIPTOR securityDescriptor)
        {
            DWORD sdLength = NativeMethods.GetSecurityDescriptorLength(securityDescriptor);

            byte[] buffer = new byte[sdLength];
            Marshal.Copy(securityDescriptor, buffer, 0, (int)sdLength);

            return buffer;
        }
Esempio n. 15
0
		public static extern BOOL GetSecurityDescriptorSacl(
			PSECURITY_DESCRIPTOR pSecurityDescriptor, 
			out BOOL lpbSaclPresent, 
			ref PACL pSacl,     // By ref, because if "present" == false, value is unchanged
			out BOOL lpbSaclDefaulted
			);
Esempio n. 16
0
		public static extern BOOL GetFileSecurity(
			LPCTSTR lpFileName, 
			SECURITY_INFORMATION RequestedInformation, 
			PSECURITY_DESCRIPTOR pSecurityDescriptor, 
			DWORD nLength, 
			out DWORD lpnLengthNeeded
			);
Esempio n. 17
0
 public static extern BOOL SetSecurityDescriptorDacl(
     PSECURITY_DESCRIPTOR pSecurityDescriptor,
     BOOL bDaclPresent,
     PACL pDacl,
     BOOL bDaclDefaulted
     );
Esempio n. 18
0
 public static extern DWORD GetSecurityDescriptorLength(
     PSECURITY_DESCRIPTOR pSecurityDescriptor
     );
Esempio n. 19
0
 public static extern BOOL GetSecurityDescriptorSacl(
     PSECURITY_DESCRIPTOR pSecurityDescriptor,
     out BOOL lpbSaclPresent,
     ref PACL pSacl,                 // By ref, because if "present" == false, value is unchanged
     out BOOL lpbSaclDefaulted
     );
Esempio n. 20
0
 public static extern BOOL SetKernelObjectSecurity(
     HANDLE Handle,
     SECURITY_INFORMATION SecurityInformation,
     PSECURITY_DESCRIPTOR SecurityDescriptor
     );
Esempio n. 21
0
 public static extern BOOL GetSecurityDescriptorControl(
     PSECURITY_DESCRIPTOR pSecurityDescriptor,
     out SECURITY_DESCRIPTOR_CONTROL pControl,
     out DWORD lpdwRevision
     );
Esempio n. 22
0
 public static extern BOOL SetSecurityDescriptorOwner(
     PSECURITY_DESCRIPTOR pSecurityDescriptor,
     PSID pOwner,
     BOOL bOwnerDefaulted
     );
Esempio n. 23
0
 public static extern LONG RegGetKeySecurity(
     HKEY hKey,                                // handle to key
     SECURITY_INFORMATION SecurityInformation, // request
     PSECURITY_DESCRIPTOR pSecurityDescriptor, // SD
     ref DWORD lpcbSecurityDescriptor          // buffer size
     );
Esempio n. 24
0
		public static extern DWORD GetNamedSecurityInfo(
			LPCTSTR pObjectName,		//REVIEW: Why is it documented as LPTSTR
			SE_OBJECT_TYPE ObjectType,
			SECURITY_INFORMATION SecurityInfo,
			ref PSID ppsidOwner,
			ref PSID ppsidGroup,
			ref PACL ppDacl,
			ref PACL ppSacl,
			ref PSECURITY_DESCRIPTOR ppSecurityDescriptor);
Esempio n. 25
0
 /// <summary>Converts a security descriptor to its SDDL string format.</summary>
 /// <param name="pSD">The security descriptor.</param>
 /// <param name="si">The elements of the security descriptor to return.</param>
 /// <returns>The SDDL string representation of the security descriptor.</returns>
 public static string ToSddl(this PSECURITY_DESCRIPTOR pSD, SECURITY_INFORMATION si) => ConvertSecurityDescriptorToStringSecurityDescriptor(pSD, si);
Esempio n. 26
0
		public static extern BOOL SetSecurityDescriptorSacl(
			PSECURITY_DESCRIPTOR pSecurityDescriptor, 
			BOOL bSaclPresent, 
			PACL pSacl, 
			BOOL bSaclDefaulted
			);
Esempio n. 27
0
		public static extern DWORD GetSecurityInfo(
			HANDLE handle,
			SE_OBJECT_TYPE ObjectType,
			SECURITY_INFORMATION SecurityInfo,
			ref PSID ppsidOwner,
			ref PSID ppsidGroup,
			ref PACL ppDacl,
			ref PACL ppSacl,
			ref PSECURITY_DESCRIPTOR ppSecurityDescriptor);
Esempio n. 28
0
		public static extern BOOL SetSecurityDescriptorOwner(
			PSECURITY_DESCRIPTOR pSecurityDescriptor, 
			PSID pOwner, 
			BOOL bOwnerDefaulted
			);
Esempio n. 29
0
		public static extern BOOL SetSecurityDescriptorGroup(
			PSECURITY_DESCRIPTOR pSecurityDescriptor, 
			PSID pGroup, 
			BOOL bGroupDefaulted
			);
Esempio n. 30
0
		public static extern BOOL SetSecurityDescriptorControl(
			PSECURITY_DESCRIPTOR pSecurityDescriptor, 
			SECURITY_DESCRIPTOR_CONTROL ControlBitsOfInterest, 
			SECURITY_DESCRIPTOR_CONTROL ControlBitsToSet
			);
Esempio n. 31
0
 public static extern BOOL SetSecurityDescriptorControl(
     PSECURITY_DESCRIPTOR pSecurityDescriptor,
     SECURITY_DESCRIPTOR_CONTROL ControlBitsOfInterest,
     SECURITY_DESCRIPTOR_CONTROL ControlBitsToSet
     );
Esempio n. 32
0
        /// <summary>
        /// Gets the effective permissions for the provided Sid within the Security Descriptor.
        /// </summary>
        /// <param name="pUserSid">A pointer to the Sid of the identity to check.</param>
        /// <param name="serverName">Name of the server. This can be <c>null</c>.</param>
        /// <param name="pSecurityDescriptor">A pointer to the security descriptor.</param>
        /// <returns>An array of access masks.</returns>
        public virtual ACCESS_MASK[] GetEffectivePermission(PSID pUserSid, string serverName, PSECURITY_DESCRIPTOR pSecurityDescriptor)
        {
            ACCESS_MASK mask = pSecurityDescriptor.GetEffectiveRights(pUserSid);

            return(new[] { mask });
        }
Esempio n. 33
0
		public static extern BOOL MakeSelfRelativeSD(
			PSECURITY_DESCRIPTOR pAbsoluteSD, 
			PSECURITY_DESCRIPTOR pSelfRelativeSD, 
			ref DWORD lpdwBufferLength
			);
Esempio n. 34
0
 public static extern BOOL SetFileSecurity(
     LPCTSTR lpFileName, // file name
     SECURITY_INFORMATION SecurityInformation, // contents
     PSECURITY_DESCRIPTOR pSecurityDescriptor // SD
     );
Esempio n. 35
0
 public static extern BOOL SetSecurityDescriptorGroup(
     PSECURITY_DESCRIPTOR pSecurityDescriptor,
     PSID pGroup,
     BOOL bGroupDefaulted
     );
Esempio n. 36
0
 public static extern LONG RegGetKeySecurity(
     HKEY hKey,                                // handle to key
     SECURITY_INFORMATION SecurityInformation, // request
     PSECURITY_DESCRIPTOR pSecurityDescriptor, // SD
     ref DWORD lpcbSecurityDescriptor            // buffer size
     );
Esempio n. 37
0
 public static extern BOOL SetFileSecurity(
     LPCTSTR lpFileName,                       // file name
     SECURITY_INFORMATION SecurityInformation, // contents
     PSECURITY_DESCRIPTOR pSecurityDescriptor  // SD
     );
Esempio n. 38
0
 public static extern LONG RegSetKeySecurity(
     HKEY hKey,
     SECURITY_INFORMATION SecurityInformation,
     PSECURITY_DESCRIPTOR pSecurityDescriptor
     );
Esempio n. 39
0
 public static extern LONG RegSetKeySecurity(
     HKEY hKey,
     SECURITY_INFORMATION SecurityInformation,
     PSECURITY_DESCRIPTOR pSecurityDescriptor
     );
Esempio n. 40
0
		public static extern BOOL GetKernelObjectSecurity(
			HANDLE Handle,                             // handle to object
			SECURITY_INFORMATION RequestedInformation, // request
			PSECURITY_DESCRIPTOR pSecurityDescriptor,  // SD
			DWORD nLength,                             // size of SD
			out DWORD lpnLengthNeeded                    // required size of buffer
			);
Esempio n. 41
0
 public static extern BOOL InitializeSecurityDescriptor(PSECURITY_DESCRIPTOR pSecurityDescriptor, DWORD dwRevision);
Esempio n. 42
0
		public static extern BOOL SetKernelObjectSecurity(
			HANDLE Handle,
			SECURITY_INFORMATION SecurityInformation,
			PSECURITY_DESCRIPTOR SecurityDescriptor
			);
Esempio n. 43
0
 public static extern BOOL GetSecurityDescriptorGroup(
     PSECURITY_DESCRIPTOR pSecurityDescriptor,
     out PSID pGroup,
     out BOOL lpbGroupDefaulted
     );
Esempio n. 44
0
 /// <summary>Determines whether the security descriptor is self-relative.</summary>
 /// <param name="pSD">The pointer to the SECURITY_DESCRIPTOR structure to query.</param>
 /// <returns><c>true</c> if it is self-relative; otherwise, <c>false</c>.</returns>
 public static bool IsSelfRelative(this PSECURITY_DESCRIPTOR pSD) => GetSecurityDescriptorControl(pSD, out var ctrl, out _) ? ctrl.IsFlagSet(SECURITY_DESCRIPTOR_CONTROL.SE_SELF_RELATIVE) : throw Win32Error.GetLastError().GetException();
Esempio n. 45
0
 public static extern BOOL GetSecurityDescriptorOwner(
     PSECURITY_DESCRIPTOR pSecurityDescriptor,
     out PSID pOwner,
     out BOOL lpbOwnerDefaulted
     );
Esempio n. 46
0
 /// <summary>Determines whether the components of a security descriptor are valid.</summary>
 /// <param name="pSD">The pointer to the SECURITY_DESCRIPTOR structure to query.</param>
 /// <returns>
 /// <c>true</c> if the components of the security descriptor are valid. If any of the components of the security descriptor are not
 /// valid, the return value is <c>false</c>.
 /// </returns>
 public static bool IsValidSecurityDescriptor(this PSECURITY_DESCRIPTOR pSD) => AdvApi32.IsValidSecurityDescriptor(pSD);
Esempio n. 47
0
 public static extern BOOL MakeSelfRelativeSD(
     PSECURITY_DESCRIPTOR pAbsoluteSD,
     PSECURITY_DESCRIPTOR pSelfRelativeSD,
     ref DWORD lpdwBufferLength
     );
Esempio n. 48
0
 /// <summary>Gets the size, in bytes, of a security descriptor. If it is not valid, 0 is returned.</summary>
 /// <param name="pSD">The pointer to the SECURITY_DESCRIPTOR structure to query.</param>
 /// <returns>The size, in bytes, of a security descriptor. If it is not valid, 0 is returned.</returns>
 public static uint Length(this PSECURITY_DESCRIPTOR pSD) => IsValidSecurityDescriptor(pSD) ? GetSecurityDescriptorLength(pSD) : 0U;
Esempio n. 49
0
 /// <summary>
 /// Gets the effective permissions for the provided Sid within the Security Descriptor.
 /// Called only when an object type identifier is specified.
 /// </summary>
 /// <param name="objTypeId">The object type identifier.</param>
 /// <param name="pUserSid">A pointer to the Sid of the identity to check.</param>
 /// <param name="serverName">Name of the server. This can be <c>null</c>.</param>
 /// <param name="pSecurityDescriptor">A pointer to the security descriptor.</param>
 /// <param name="objectTypeList">The object type list.</param>
 /// <returns>An array of access masks.</returns>
 /// <exception cref="System.NotImplementedException"></exception>
 public virtual uint[] GetEffectivePermission(Guid objTypeId, PSID pUserSid, string serverName, PSECURITY_DESCRIPTOR pSecurityDescriptor, out OBJECT_TYPE_LIST[] objectTypeList)
 {
     throw new NotImplementedException();
 }
Esempio n. 50
-2
		public static extern BOOL MakeAbsoluteSD(
			PSECURITY_DESCRIPTOR pSelfRelativeSD, 
			PSECURITY_DESCRIPTOR pAbsoluteSD, 
			ref DWORD lpdwAbsoluteSDSize, 
			PACL pDacl, 
			ref DWORD lpdwDaclSize, 
			PACL pSacl, 
			ref DWORD lpdwSaclSize, 
			PSID pOwner, 
			ref DWORD lpdwOwnerSize, 
			PSID pPrimaryGroup, 
			ref DWORD lpdwPrimaryGroupSize
			);