【问题标题】:BizTalk Service AuthorizationBizTalk 服务授权
【发布时间】:2011-11-07 13:48:01
【问题描述】:

我正在尝试按照 Seroter 描述的here(服务授权部分)实施授权。我已经对库进行了 GAC,更改了 machine.config 并能够在 Select Behavior Extension 对话框中选择自定义行为。但我无法设置“WindowsGroup”值,它给了我“对象引用未设置为对象的实例”,我不知道为什么。有人实现了服务授权吗?

【问题讨论】:

    标签: wcf authentication biztalk


    【解决方案1】:

    终于解决了这个问题。

    using System;
    using System.Configuration;
    using System.ServiceModel.Configuration;
    
    namespace Esb.Service.Authorization
    {
        public class EsbBehaviorElement : BehaviorExtensionElement
        {
            private const string _windowsgroupIndexName = "windowsgroup";
    
            public EsbBehaviorElement()
            {
                if (!base.Properties.Contains(_windowsgroupIndexName))
                {
                    base.Properties.Add(new ConfigurationProperty(_windowsgroupIndexName, typeof(string)));
                }
            }
    
            [ConfigurationProperty("WindowsGroup", IsRequired = false, DefaultValue = "")]
            public string WindowsGroup
            {
                get
                {
                    return (string)base[_windowsgroupIndexName];
                }
                set
                {
                    base[_windowsgroupIndexName] = value;
                }
            }
    
            public override Type BehaviorType
            {
                get
                {
                    return typeof(EsbServiceBehavior);
                }
            }
    
            protected override object CreateBehavior()
            {
                return new EsbServiceBehavior(WindowsGroup);
            }
        }
    }
    

    我不知道为什么 Seroter 的解决方案可以在没有 ctor 的情况下工作,应该将“windowsgroup”属性添加到属性的基本集合中。

    【讨论】:

    • 感谢您发布解决方案!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-01-21
    • 2019-03-15
    • 2011-04-09
    • 2011-07-07
    • 1970-01-01
    • 1970-01-01
    • 2017-11-19
    相关资源
    最近更新 更多