• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# AccessControlSections类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中AccessControlSections的典型用法代码示例。如果您正苦于以下问题:C# AccessControlSections类的具体用法?C# AccessControlSections怎么用?C# AccessControlSections使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



AccessControlSections类属于命名空间,在下文中一共展示了AccessControlSections类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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


示例16: Persist

 protected virtual void Persist(string name, AccessControlSections includeSections);
开发者ID:scott156,项目名称:corefx-progress,代码行数:1,代码来源:System.Security.AccessControl.cs


示例17: GetSecurityDescriptorSddlForm

 public string GetSecurityDescriptorSddlForm(AccessControlSections includeSections);
开发者ID:scott156,项目名称:corefx-progress,代码行数:1,代码来源:System.Security.AccessControl.cs


示例18: NativeObjectSecurity

 protected NativeObjectSecurity(bool isContainer, ResourceType resourceType, string name, AccessControlSections includeSections, NativeObjectSecurity.ExceptionFromErrorCode exceptionFromErrorCode, object exceptionContext);
开发者ID:scott156,项目名称:corefx-progress,代码行数:1,代码来源:System.Security.AccessControl.cs


示例19: SetSecurityDescriptorBinaryForm

 public void SetSecurityDescriptorBinaryForm(byte[] binaryForm, AccessControlSections includeSections);
开发者ID:scott156,项目名称:corefx-progress,代码行数:1,代码来源:System.Security.AccessControl.cs


示例20: SetSecurityDescriptorSddlForm

 public void SetSecurityDescriptorSddlForm(string sddlForm, AccessControlSections includeSections);
开发者ID:scott156,项目名称:corefx-progress,代码行数:1,代码来源:System.Security.AccessControl.cs



注:本文中的AccessControlSections类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# AccessControlType类代码示例发布时间:2022-05-24
下一篇:
C# AccessControlModification类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap