
    %
i!                     ,   d dl Z d dlZd dlZd dlZd dlZd dlZd dlmZm	Z	m
Z
mZmZmZmZmZmZmZmZmZmZmZmZmZ d dlmZ d dlmZ d dlmZmZ  G d dej        j        j                  Z  ej!                    Z" ej#        e"d          d          Z$ e%e$            e j&        e$            e j'        e$            e e$          Z(e()                                  ej#        e$d          d          Z* e e*          Z(e()                                 dS )	    N)FILE_ALL_ACCESSFILE_APPEND_DATAFILE_GENERIC_EXECUTEFILE_GENERIC_READFILE_GENERIC_WRITEFILE_WRITE_DATAREAD_CONTROLSI_ACCESS_GENERALSI_ACCESS_SPECIFICSI_ADVANCEDSI_CONTAINERSI_EDIT_ALLSI_PAGE_TITLESI_RESET	WRITE_DACWRITE_OWNER)IID_NULL)authorization)CONTAINER_INHERIT_ACEOBJECT_INHERIT_ACEc                   ^    e Zd Zej        gZg dZd Zd Zd Z	d Z
d Zd Zd Zd	 ZddZdS )SecurityInformation)GetObjectInformationGetSecuritySetSecurityGetAccessRightsGetInheritTypes
MapGenericPropertySheetPageCallbackc                 >    || _         |                     |            d S )N)FileName_wrap_)selfr!   s     C:\Users\Dell Inspiron 16\Desktop\tws\AgrotaPowerBi\back-agrota-powerbi\mcp-client-agrota\venv\Lib\site-packages\win32comext/authorization/demos/EditSecurity.py__init__zSecurityInformation.__init__+   s!     D    c                 x   t           t          z  t          z  t          z  }t          j                            | j                  r
|t          z  }d}d}t          j        	                    | j                  d         }d}t          j                            | j                  r|dz  }n|dz  }t          }||||||fS )zkIdentifies object whose security will be modified, and determines options available
        to the end userr       zPython ACL Editorz (dir)z (file))r   r   r   r   ospathisdirr!   r   splitr   )r#   flags	hinstance
servername
objectname	pagetitle
objecttypes          r$   r   z(SecurityInformation.GetObjectInformation/   s     k)M9HD7=='' 	"\!E	
W]]4=11!4
'	7=='' 	#!II"I
iZJNNr&   c                 v    |rt          j                    S t          j        | j        t           j        |          S )z,Requests the existing permissions for object)win32securitySECURITY_DESCRIPTORGetNamedSecurityInfor!   SE_FILE_OBJECT)r#   requestedinfobdefaults      r$   r   zSecurityInformation.GetSecurity@   s>     		 !4666 !5};]  r&   c           	          |                                 }|                                }|                                }|                                }t	          j        | j        t          j        |||||           dS )z!Applies permissions to the objectN)GetSecurityDescriptorOwnerGetSecurityDescriptorGroupGetSecurityDescriptorDaclGetSecurityDescriptorSaclr5   SetNamedSecurityInfor!   r8   )r#   r9   sdownergroupdaclsacls          r$   r   zSecurityInformation.SetSecurityM   s    --//--//++--++--*M(	
 	
 	
 	
 	
r&   c                 
   ||t           k    rt          d          t          j                            | j                  rd}d}nd}d}t           t          dt          t          z  t          z  t          z  ft           t          dt          t          z  t          z  t          z  ft           t          j        d	t          t          z  t          z  ft           t          d
t          t          z  t          z  ft           t          dt          t          z  t          z  ft           t           dt          t          z  t          z  ft           t"          |t          t          z  t          z  ft           t$          |t          t          z  t          z  fg}|dfS )a  Returns a tuple of (AccessRights, DefaultAccess), where AccessRights is a sequence of tuples representing
        SI_ACCESS structs, containing (guid, access mask, Name, flags). DefaultAccess indicates which of the
        AccessRights will be used initially when a new ACE is added (zero based).
        Flags can contain SI_ACCESS_SPECIFIC,SI_ACCESS_GENERAL,SI_ACCESS_CONTAINER,SI_ACCESS_PROPERTY,
              CONTAINER_INHERIT_ACE,INHERIT_ONLY_ACE,OBJECT_INHERIT_ACE
        NzObject type is not supportedzCreate subfolderszCreate FileszAppend dataz
Write datazGeneric readzGeneric writeDeletezChange ownerzRead PermissionszChange permissionsr   )r   NotImplementedErrorr*   r+   r,   r!   r   r
   r   r   r   r   win32conDELETEr   r	   r   r   r   )r#   r3   r.   file_append_data_descfile_write_data_descaccessrightss         r$   r   z#SecurityInformation.GetAccessRights^   s    "x)?)? &&DEEE7=='' 	0$7!#1  $1!#/  !!$%$% ((	 "!$%$% ((	 "%77:OO	 "%77:OO	 ""%77:OO	 $"%77:OO	  %"%77:OO	 $"%77:OO	c7
p a  r&   c                 \    t          j        |t          t          t          t
          f          S )zConverts generic access rights to specific rights.  This implementation uses standard file system rights,
        but you can map them any way that suits your application.
        )r5   MapGenericMaskr   r   r   r   )r#   guidaceflagsmasks       r$   r   zSecurityInformation.MapGeneric   s-     +!"$	
 
 	
r&   c                 |    t           ddft           t          dft           t          dft           t          t          z  dffS )a  Specifies which types of ACE inheritance are supported.
        Returns a sequence of tuples representing SI_INHERIT_TYPE structs, containing
        (object type guid, inheritance flags, display name).  Guid is usually only used with
        Directory Service objects.
        r   zOnly current objectzFiles inherit permissionszSub Folders inherit permissionszFiles and subfolders)r   r   r   )r#   s    r$   r   z#SecurityInformation.GetInheritTypes   sE     q/0)+FG,.OP%(::&		
 		
r&   c                     dS )z@Invoked each time a property sheet page is created or destroyed.N )r#   hwndmsgpagetypes       r$   r   z-SecurityInformation.PropertySheetPageCallback   s	     tr&   r   c                     t          j        | t          j        t           j                  }t          j        ||           dS )zNCreates an ACL editor dialog based on parameters returned by interface methodsN)	pythoncom
WrapObjectr   IID_ISecurityInformationIID_IUnknownEditSecurity)r#   
owner_hwndisis      r$   r^   z SecurityInformation.EditSecurity   s<    "-8):P
 
 	":s33333r&   N)r   )__name__
__module____qualname__r   r\   _com_interfaces__public_methods_r%   r   r   r   r   r   r   r   r^   rU   r&   r$   r   r      s        %>?    O O O"  
 
 
"L! L! L!\
 
 

 
 
"  4 4 4 4 4 4r&   r   r`   )+r*   rZ   win32apiwin32com.server.policywin32comrI   r5   ntsecurityconr   r   r   r   r   r   r	   r
   r   r   r   r   r   r   r   r   r   win32com.authorizationr   r   r   serverpolicyDesignatedWrapPolicyr   GetTempPathtemp_dirGetTempFileNamedir_nameprintremovemkdirsir^   fnamerU   r&   r$   <module>rw      s.   				                                                 $       0 0 0 0 0 0 C C C C C C C Cw4 w4 w4 w4 w4(/0E w4 w4 w4v  8!!#8#He44Q7 h 		(       ""     	! 511!4      r&   