2015-07-29 3 views
1

Мне нужно использовать dll Microsoft.IdentityModel в пакете SSIS.Использование Microsoft.IdentityModel в пакете SSIS

В обычном C# приложения, я хотел бы добавить сборки в файл app.config, как показывают на этом сайте adding Microsoft.IdentityModel

Но я не могу использовать это в SSIS, потому что их не app.config в скрипте компонент.

Я попытался добавить app.config и добавить разделы в app.config, но это не сработает.

Я также попытался импортировать XML-файл для конфигурации пакета.

Также точная ошибка, я получаю, когда я отладки моего сценария:

"ID7027: Could not load the identity configuration 
because no <system.identityModel> configuration section was found." 

ответ

1

Мы использовали SecurityTokenHandlerCollection handlers = FederatedAuthentication.FederationConfiguration.IdentityConfiguration.SecurityTokenHandlers; получить обработчик.

Мы изменили его использовать

    SecurityTokenHandlerCollection collection = SecurityTokenHandlerCollection.CreateDefaultSecurityTokenHandlerCollection(); 

       token = collection.ReadToken(xmlReader.ReadSubtree()); 

Вот как используется код

 private static SecurityToken ConvertBearerTokenTextToSecurityToken(string tokenText) 
    { 
     SecurityToken token = null; 

     // ConfigSections must be added to App.Config in order for this line to work - this section must be right after the <configuration> node 

     //<configSections> 
     // <!--WIF 4.5 sections --> 
     // <section name="system.identityModel" type="System.IdentityModel.Configuration.SystemIdentityModelSection, System.IdentityModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/> 
     // <section name="system.identityModel.services" type="System.IdentityModel.Services.Configuration.SystemIdentityModelServicesSection, System.IdentityModel.Services, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/> 
     //</configSections> 

     //SecurityTokenHandlerCollection handlers = FederatedAuthentication.FederationConfiguration.IdentityConfiguration.SecurityTokenHandlers; 

     using (StringReader stringReader = new StringReader(tokenText)) 
     { 
      using (XmlTextReader xmlReader = new XmlTextReader(stringReader)) 
      { 
       if (!xmlReader.ReadToFollowing("Assertion")) 
       { 
        throw new Exception("Assertion not found!"); 
       } 

       SecurityTokenHandlerCollection collection = SecurityTokenHandlerCollection.CreateDefaultSecurityTokenHandlerCollection(); 

       token = collection.ReadToken(xmlReader.ReadSubtree()); 
      } 
     } 

     return token; 
    } 
Смежные вопросы