當前位置: 首頁>>代碼示例>>C#>>正文


C# AccessControlSections類代碼示例

本文整理匯總了C#中AccessControlSections的典型用法代碼示例。如果您正苦於以下問題:C# AccessControlSections類的具體用法?C# AccessControlSections怎麽用?C# AccessControlSections使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


AccessControlSections類屬於命名空間,在下文中一共展示了AccessControlSections類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: GetSddlForm

    public string GetSddlForm(AccessControlSections includeSections)
    {
      Contract.Requires(3 < this.BinaryLength);
      Contract.Ensures(System.Security.AccessControl.GenericSecurityDescriptor.Revision == 1);

      return default(string);
    }
開發者ID:asvishnyakov,項目名稱:CodeContracts,代碼行數:7,代碼來源:System.Security.AccessControl.GenericSecurityDescriptor.cs

示例2: GetAccessControl

		public static RegistrySecurity GetAccessControl (this RegistryKey key, AccessControlSections includeSections)
		{
			if (key == null)
				throw new ArgumentNullException (nameof (key));

			return key.GetAccessControl (includeSections);
		}
開發者ID:ItsVeryWindy,項目名稱:mono,代碼行數:7,代碼來源:RegistryAclExtensions.cs

示例3: GetAccessControl

 public ObjectSecurity GetAccessControl(AccessControlSections includeSections)
 {
     using (this.provider.CurrentPSTransaction)
     {
         return this.txRegKey.GetAccessControl(includeSections);
     }
 }
開發者ID:nickchal,項目名稱:pash,代碼行數:7,代碼來源:TransactedRegistryWrapper.cs

示例4: GetAccessControl

		public static FileSecurity GetAccessControl(this FileInfo fileInfo, AccessControlSections includeSections)
		{
			if (fileInfo == null)
				throw new ArgumentNullException (nameof (fileInfo));

			return fileInfo.GetAccessControl (includeSections);
		}
開發者ID:ItsVeryWindy,項目名稱:mono,代碼行數:7,代碼來源:FileSystemAclExtensions.cs

示例5: NativeObjectSecurity

		protected NativeObjectSecurity (bool isContainer,
						ResourceType resourceType,
						string name,
						AccessControlSections includeSections)
			: this (isContainer, resourceType, name, includeSections, null, null)
		{
		}
開發者ID:Profit0004,項目名稱:mono,代碼行數:7,代碼來源:NativeObjectSecurity.cs

示例6: GetSecurityDescriptor

        /// <summary>
        /// Gets the security descriptor for the item specified by <paramref name="path"/>.
        /// </summary>
        /// 
        /// <param name="path">
        /// The path to the item.
        /// </param>
        ///
        /// <param name="sections">
        /// Specifies the parts of a security descriptor to retrieve.
        /// </param>
        /// 
        /// <returns>
        /// Nothing. An object that represents the security descriptor for the item
        /// specified by path is written to the WriteSecurityDescriptorObject method.
        /// </returns>
        public void GetSecurityDescriptor(string path,
                                          AccessControlSections sections)
        {
            ObjectSecurity sd = null;
            IRegistryWrapper key = null;

            // Validate input first.
            if (String.IsNullOrEmpty(path))
            {
                throw PSTraceSource.NewArgumentNullException("path");
            }

            if ((sections & ~AccessControlSections.All) != 0)
            {
                throw PSTraceSource.NewArgumentException("sections");
            }

            path = NormalizePath(path);

            key = GetRegkeyForPathWriteIfError(path, false);

            if (key != null)
            {
                try
                {
                    sd = key.GetAccessControl(sections);
                }
                catch (System.Security.SecurityException e)
                {
                    WriteError(new ErrorRecord(e, e.GetType().FullName, ErrorCategory.PermissionDenied, path));
                    return;
                }
                WriteSecurityDescriptorObject(sd, path);
            }
        }
開發者ID:40a,項目名稱:PowerShell,代碼行數:51,代碼來源:RegistrySecurity.cs

示例7: CreateInternal

        private static CommonSecurityDescriptor CreateInternal(ResourceType resourceType, bool isContainer, string name, SafeHandle handle, AccessControlSections includeSections, bool createByName, ExceptionFromErrorCode exceptionFromErrorCode, object exceptionContext)
        {
            RawSecurityDescriptor descriptor;
            if (createByName && (name == null))
            {
                throw new ArgumentNullException("name");
            }
            if (!createByName && (handle == null))
            {
                throw new ArgumentNullException("handle");
            }
            int errorCode = System.Security.AccessControl.Win32.GetSecurityInfo(resourceType, name, handle, includeSections, out descriptor);
            if (errorCode == 0)
            {
                return new CommonSecurityDescriptor(isContainer, false, descriptor, true);
            }
            Exception exception = null;
            if (exceptionFromErrorCode != null)
            {
                exception = exceptionFromErrorCode(errorCode, name, handle, exceptionContext);
            }
            if (exception == null)
            {
                switch (errorCode)
                {
                    case 5:
                        exception = new UnauthorizedAccessException();
                        goto Label_0132;

                    case 0x51b:
                        exception = new InvalidOperationException(Environment.GetResourceString("AccessControl_InvalidOwner"));
                        goto Label_0132;

                    case 0x51c:
                        exception = new InvalidOperationException(Environment.GetResourceString("AccessControl_InvalidGroup"));
                        goto Label_0132;

                    case 0x57:
                        exception = new InvalidOperationException(Environment.GetResourceString("AccessControl_UnexpectedError", new object[] { errorCode }));
                        goto Label_0132;

                    case 0x7b:
                        exception = new ArgumentException(Environment.GetResourceString("Argument_InvalidName"), "name");
                        goto Label_0132;

                    case 2:
                        exception = (name == null) ? new FileNotFoundException() : new FileNotFoundException(name);
                        goto Label_0132;

                    case 0x546:
                        exception = new NotSupportedException(Environment.GetResourceString("AccessControl_NoAssociatedSecurity"));
                        goto Label_0132;
                }
                exception = new InvalidOperationException(Environment.GetResourceString("AccessControl_UnexpectedError", new object[] { errorCode }));
            }
        Label_0132:
            throw exception;
        }
開發者ID:pritesh-mandowara-sp,項目名稱:DecompliedDotNetLibraries,代碼行數:58,代碼來源:NativeObjectSecurity.cs

示例8: NativeObjectSecurity

		protected NativeObjectSecurity (bool isContainer,
						ResourceType resourceType,
						SafeHandle handle,
						AccessControlSections includeSections,
						ExceptionFromErrorCode exceptionFromErrorCode,
						object exceptionContext)
			: this (isContainer, resourceType, handle, includeSections)
		{
		}
開發者ID:runefs,項目名稱:Marvin,代碼行數:9,代碼來源:NativeObjectSecurity.cs

示例9: GetAccessControl

        public static RegistrySecurity GetAccessControl(this RegistryKey key, AccessControlSections includeSections)
        {
            if (key.Handle == null)
            {
                throw new ObjectDisposedException(key.Name, SR.ObjectDisposed_RegKeyClosed);
            }

            return new RegistrySecurity(key.Handle, key.Name, includeSections);
        }
開發者ID:ChuangYang,項目名稱:corefx,代碼行數:9,代碼來源:RegistryAclExtensions.cs

示例10: FileSecurity

 internal FileSecurity(SafeFileHandle handle, string fullPath, AccessControlSections includeSections) : base(false, handle, includeSections, false)
 {
     if (fullPath != null)
     {
         new FileIOPermission(FileIOPermissionAccess.NoAccess, AccessControlActions.View, fullPath).Demand();
     }
     else
     {
         new FileIOPermission(PermissionState.Unrestricted).Demand();
     }
 }
開發者ID:pritesh-mandowara-sp,項目名稱:DecompliedDotNetLibraries,代碼行數:11,代碼來源:FileSecurity.cs

示例11: TryGetFileSecurity

        private static bool TryGetFileSecurity(string path, AccessControlSections sectionsNeeded,
            out FileSystemSecurity security)
        {
            var exists = false;
            security = null;

            if (File.Exists(path))
            {
                exists = true;
                security = File.GetAccessControl(path, sectionsNeeded);
            }

            return exists;
        }
開發者ID:stefanschneider,項目名稱:IronFrame,代碼行數:14,代碼來源:FileSystemSecurityDescriptorReader.cs

示例12: TryGetDirectorySecurity

        private bool TryGetDirectorySecurity(string path, AccessControlSections sectionsNeeded,
            out FileSystemSecurity security)
        {
            var exists = false;
            security = null;

            if (Directory.Exists(path))
            {
                exists = true;
                security = Directory.GetAccessControl(path, sectionsNeeded);
            }

            return exists;
        }
開發者ID:stefanschneider,項目名稱:IronFrame,代碼行數:14,代碼來源:FileSystemSecurityDescriptorReader.cs

示例13: GetSecurityDescriptor

        } // GetPermissionProviderInstance

        #endregion private methods

        #region GetSecurityDescriptor


        /// <summary>
        /// Gets the security descriptor from the specified item.
        /// </summary>
        /// 
        /// <param name="path">
        /// The path to the item to retrieve the security descriptor from.
        /// </param>
        /// 
        /// <param name="sections">
        /// Specifies the parts of a security descriptor to retrieve.
        /// </param>
        /// 
        /// <returns>
        /// The security descriptor for the item at the specified path.
        /// </returns>
        /// 
        internal Collection<PSObject> GetSecurityDescriptor(string path,
                                                             AccessControlSections sections)
        {
            if (path == null)
            {
                throw PSTraceSource.NewArgumentNullException("path");
            }

            CmdletProviderContext context = new CmdletProviderContext(this.ExecutionContext);

            GetSecurityDescriptor(path, sections, context);

            context.ThrowFirstErrorOrDoNothing();

            Collection<PSObject> contextResults = context.GetAccumulatedObjects() ?? new Collection<PSObject>();

            return contextResults;
        } // GetSecurityDescriptor
開發者ID:40a,項目名稱:PowerShell,代碼行數:41,代碼來源:SessionStateSecurityDescriptorInterface.cs

示例14: GetSecurityDescriptor

        /// <summary>
        /// Internal wrapper for the GetSecurityDescriptor protected method. This method will
        /// only be called if the provider implements the ISecurityDescriptorCmdletProvider interface.
        /// </summary>
        /// 
        /// <param name="path">
        /// The path to the item to retrieve the security descriptor from.
        /// </param>
        /// 
        /// <param name="sections">
        /// Specifies the parts of a security descriptor to retrieve.
        /// </param>
        /// 
        /// <param name="context">
        /// The context under which this method is being called.
        /// </param>
        /// 
        /// <returns>
        /// Nothing. An instance of an object that represents the security descriptor
        /// for the item specified by the path should be written to the context.
        /// </returns>
        /// 
        internal void GetSecurityDescriptor(
            string path,
            AccessControlSections sections,
            CmdletProviderContext context)
        {
            Context = context;

            ISecurityDescriptorCmdletProvider permissionProvider = this as ISecurityDescriptorCmdletProvider;

            //
            // if this is not supported, the fn will throw
            //
            CheckIfSecurityDescriptorInterfaceIsSupported(permissionProvider);

            // Call interface method

            permissionProvider.GetSecurityDescriptor(path, sections);
        } // GetSecurityDescriptor
開發者ID:40a,項目名稱:PowerShell,代碼行數:40,代碼來源:ProviderBaseSecurity.cs

示例15: GetSecurityDescriptor

        /// <summary>
        /// Gets the SecurityDescriptor at the specified path, including only the specified
        /// AccessControlSections.
        /// </summary>
        ///
        /// <param name="path">
        /// The path of the item to retrieve. It may be a drive or provider-qualified path and may include.
        /// glob characters.
        /// </param>
        /// 
        /// <param name="sections">
        /// The sections of the security descriptor to include.
        /// </param>
        /// 
        /// <returns>
        /// Nothing. An object that represents the security descriptor for the item
        /// specified by path is written to the context's pipeline.
        /// </returns>
        /// 
        /// <exception cref="System.ArgumentException">
        ///     path is null or empty.
        ///     path doesn't exist
        ///     sections is not valid.
        /// </exception>
        public void GetSecurityDescriptor(string path,
                                          AccessControlSections sections)
        {
            ObjectSecurity sd = null;
            path = NormalizePath(path);

            if (String.IsNullOrEmpty(path))
            {
                throw PSTraceSource.NewArgumentNullException("path");
            }

            if ((sections & ~AccessControlSections.All) != 0)
            {
                throw PSTraceSource.NewArgumentException("sections");
            }

            var currentPrivilegeState = new PlatformInvokes.TOKEN_PRIVILEGE();
            try
            {
                PlatformInvokes.EnableTokenPrivilege("SeBackupPrivilege", ref currentPrivilegeState);

                if (Directory.Exists(path))
                {
                    sd = new DirectorySecurity(path, sections);
                }
                else
                {
                    sd = new FileSecurity(path, sections);
                }
            }
            catch (System.Security.SecurityException e)
            {
                WriteError(new ErrorRecord(e, e.GetType().FullName, ErrorCategory.PermissionDenied, path));
            }
            finally
            {
                PlatformInvokes.RestoreTokenPrivilege("SeBackupPrivilege", ref currentPrivilegeState);
            }

            WriteSecurityDescriptorObject(sd, path);
        }
開發者ID:40a,項目名稱:PowerShell,代碼行數:65,代碼來源:FileSystemSecurity.cs


注:本文中的AccessControlSections類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。