当前位置: 首页>>代码示例>>C#>>正文


C# CmdletProvider.SetSecurityDescriptor方法代码示例

本文整理汇总了C#中System.Management.Automation.Provider.CmdletProvider.SetSecurityDescriptor方法的典型用法代码示例。如果您正苦于以下问题:C# CmdletProvider.SetSecurityDescriptor方法的具体用法?C# CmdletProvider.SetSecurityDescriptor怎么用?C# CmdletProvider.SetSecurityDescriptor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Management.Automation.Provider.CmdletProvider的用法示例。


在下文中一共展示了CmdletProvider.SetSecurityDescriptor方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SetSecurityDescriptor

 private void SetSecurityDescriptor(CmdletProvider providerInstance, string path, ObjectSecurity securityDescriptor, CmdletProviderContext context)
 {
     GetPermissionProviderInstance(providerInstance);
     try
     {
         providerInstance.SetSecurityDescriptor(path, securityDescriptor, context);
     }
     catch (LoopFlowException)
     {
         throw;
     }
     catch (PipelineStoppedException)
     {
         throw;
     }
     catch (ActionPreferenceStopException)
     {
         throw;
     }
     catch (PrivilegeNotHeldException exception)
     {
         context.WriteError(new ErrorRecord(exception, exception.GetType().FullName, ErrorCategory.PermissionDenied, path));
     }
     catch (UnauthorizedAccessException exception2)
     {
         context.WriteError(new ErrorRecord(exception2, exception2.GetType().FullName, ErrorCategory.PermissionDenied, path));
     }
     catch (NotSupportedException exception3)
     {
         context.WriteError(new ErrorRecord(exception3, exception3.GetType().FullName, ErrorCategory.InvalidOperation, path));
     }
     catch (SystemException exception4)
     {
         CommandProcessorBase.CheckForSevereException(exception4);
         context.WriteError(new ErrorRecord(exception4, exception4.GetType().FullName, ErrorCategory.InvalidOperation, path));
     }
     catch (Exception exception5)
     {
         CommandProcessorBase.CheckForSevereException(exception5);
         throw this.NewProviderInvocationException("SetSecurityDescriptorProviderException", SessionStateStrings.SetSecurityDescriptorProviderException, providerInstance.ProviderInfo, path, exception5);
     }
 }
开发者ID:nickchal,项目名称:pash,代码行数:42,代码来源:SessionStateInternal.cs

示例2: SetSecurityDescriptor

        } // SetSecurityDescriptor

        private void SetSecurityDescriptor(
            CmdletProvider providerInstance,
            string path,
            ObjectSecurity securityDescriptor,
            CmdletProviderContext context)
        {
            // All parameters should have been validated by caller
            Diagnostics.Assert(
                providerInstance != null,
                "Caller should validate providerInstance before calling this method");

            Diagnostics.Assert(
                path != null,
                "Caller should validate path before calling this method");

            Diagnostics.Assert(
                securityDescriptor != null,
                "Caller should validate securityDescriptor before calling this method");

            Diagnostics.Assert(
                context != null,
                "Caller should validate context before calling this method");

            // This just verifies that the provider supports the interface.

            GetPermissionProviderInstance(providerInstance);

            try
            {
                providerInstance.SetSecurityDescriptor(path, securityDescriptor, context);
            }
            catch (LoopFlowException)
            {
                throw;
            }
            catch (PipelineStoppedException)
            {
                throw;
            }
            catch (ActionPreferenceStopException)
            {
                throw;
            }
            catch (PrivilegeNotHeldException e)
            {
                //
                // thrown if one tries to set SACL and does not have
                // SeSecurityPrivilege
                //
                context.WriteError(new ErrorRecord(e, e.GetType().FullName, ErrorCategory.PermissionDenied, path));
            }
            catch (UnauthorizedAccessException e)
            {
                //
                // thrown if
                // -- owner or pri. group are invalid OR
                // -- marta returns ERROR_ACCESS_DENIED
                //
                context.WriteError(new ErrorRecord(e, e.GetType().FullName, ErrorCategory.PermissionDenied, path));
            }
            catch (NotSupportedException e)
            {
                //
                // thrown if path points to an item that does not
                // support access control.
                // 
                // for example, FAT or FAT32 file in case of file system provider
                //
                context.WriteError(new ErrorRecord(e, e.GetType().FullName, ErrorCategory.InvalidOperation, path));
            }
            catch (SystemException e)
            {
                CommandProcessorBase.CheckForSevereException(e);
                //
                // thrown if the CLR gets back unexpected error
                // from OS security or marta
                //
                context.WriteError(new ErrorRecord(e, e.GetType().FullName, ErrorCategory.InvalidOperation, path));
            }
            catch (Exception e) // Catch-all OK, 3rd party callout.
            {
                CommandProcessorBase.CheckForSevereException(e);
                throw NewProviderInvocationException(
                    "SetSecurityDescriptorProviderException",
                    SessionStateStrings.SetSecurityDescriptorProviderException,
                    providerInstance.ProviderInfo,
                    path,
                    e);
            }
        } // SetSecurityDescriptor
开发者ID:40a,项目名称:PowerShell,代码行数:92,代码来源:SessionStateSecurityDescriptorInterface.cs


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