首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >是否存在命令行工具CASPOL.exe的替代品?

是否存在命令行工具CASPOL.exe的替代品?
EN

Stack Overflow用户
提问于 2010-06-08 22:40:05
回答 4查看 1K关注 0票数 2

当尝试执行.NET应用程序时,它抛出一个"PolicyException",因为“只允许一个组”。该工具应列出现有设置,并允许删除所选设置。使用caspol列表是没有帮助的,它是残酷的。

我已经看到有一个简单的gui-frontend,它允许定义新的设置,但不允许列出或删除现有的设置。

卡斯波尔是一场噩梦,难怪会有人选择使用它。对于.NET 1.1,微软提供了一个配置实用程序,但是对于.NET 2.0,我什么都没有找到。

EN

回答 4

Stack Overflow用户

发布于 2010-06-08 22:46:00

还有一个针对2.0的配置Applet,我想它是随2.0 SDK一起提供的。如果你安装了它,它应该在Admin Tools中,并被称为“微软.NET Framework2.0配置”。

票数 1
EN

Stack Overflow用户

发布于 2010-06-08 22:48:41

您可以使用下面这段代码来创建自己的工具(gui或命令行):

代码语言:javascript
复制
static void SetPermission( string target ) {
    try {
        // Find the machine policy level
        PolicyLevel machinePolicyLevel = null;
        System.Collections.IEnumerator policyHierarchy = SecurityManager.PolicyHierarchy();

        while ( policyHierarchy.MoveNext() ) {
            PolicyLevel level = (PolicyLevel)policyHierarchy.Current;
            if ( level.Label == "Machine" ) {
                machinePolicyLevel = level;
                break;
            }
        }


        if ( machinePolicyLevel == null ) {
            throw new ApplicationException(
                "Could not find Machine Policy level. Code Access Security " +
                "is not configured for this application."
                );
        }

        // Create a new FullTrust permission set
        PermissionSet permissionSet = new NamedPermissionSet( "FullTrust" );

        IMembershipCondition membershipCondition = new UrlMembershipCondition( target );

        // Create the code group
        PolicyStatement policyStatement = new PolicyStatement( permissionSet );
        CodeGroup codeGroup = new UnionCodeGroup( membershipCondition, policyStatement );
        codeGroup.Description = "Custom code group created by PermSet utility.";
        codeGroup.Name = "CustomCodeGroup-" + Guid.NewGuid().ToString();

        // Add the code group
        machinePolicyLevel.RootCodeGroup.AddChild( codeGroup );

        // Save changes
        SecurityManager.SavePolicy();
    }
    catch ( Exception ex ) {
        Console.WriteLine();
        Console.WriteLine( ex.ToString() );
        throw;
    }
}
票数 1
EN

Stack Overflow用户

发布于 2010-06-08 22:48:13

该实用程序是.Net 2.0中SDK的一部分。请确保已安装该程序。

此外,您可能有兴趣知道,CAS 3.5 sp1和更高版本消除了.Net的一些痛点。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/2998337

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档