2009-09-17 10 views
7

मेरे पास SQL2005 रिपोर्टिंग सर्वर पर एक रिपोर्ट सहेजी गई है, और मैं इस रिपोर्ट के एक प्रस्तुत पीडीएफ को वापस करना चाहता हूं। स्थानीय * .rdlc फ़ाइल (and I've blogged about it) के साथ काम करते समय मैंने यह पता लगाया है, लेकिन जब * .rdl एक रिपोर्टिंग सर्वर पर रहता है। मैं लाइन पर एक 401 अधिकृत नहीं त्रुटि हो रही है ...एसएसआरएस रिपोर्ट व्यूअर + एएसपी.नेट प्रमाण पत्र 401 अपवाद

reportViewer.ServerReport.SetParameters(reportDefinition.ReportParameters); 

यहाँ रिपोर्ट प्रस्तुत करने के लिए इस्तेमाल किया विधि है।

public byte[] Render(IReportDefinition reportDefinition) 
{ 
    var reportViewer = new ReportViewer(); 
    byte[] renderedReport; 
    try 
    { 
     var credentials = new WindowsImpersonationCredentials(); 
     reportViewer.ServerReport.ReportServerUrl = new Uri("http://myssrsbox", UrlKind.Absolute); 
     reportViewer.ServerReport.ReportServerCredentials = credentials; 
     reportViewer.ServerReport.ReportPath = reportDefinition.Path; 
     // Exception is thrown on the following line... 
     reportViewer.ServerReport.SetParameters(reportDefinition.ReportParameters); 

     string mimeType; 
     string encoding; 
     string filenameExtension; 
     string[] streams; 
     Warning[] warnings; 

     renderedReport = reportViewer.ServerReport.Render(reportDefinition.OutputType, reportDefinition.DeviceInfo, out mimeType, out encoding, out filenameExtension, out streams, out warnings); 
    } 
    catch (Exception ex) 
    { 
     // log the error... 
     throw; 
    } 
    finally 
    { 
     reportViewer.Dispose(); 
    } 
    return renderedReport; 
} 

दूसरी बात यह है कि आप भूल रहे हैं WindowsImpersonationCredentials वर्ग है।

public class WindowsImpersonationCredentials : IReportServerCredentials 
{ 
    public bool GetFormsCredentials(out Cookie authCookie, out string userName, out string password, out string authority) 
    { 
     authCookie = null; 
     userName = password = authority = null; 
     return false; 
    } 

    public WindowsIdentity ImpersonationUser 
    { 
     get { return WindowsIdentity.GetCurrent(); } 
    } 

    public ICredentials NetworkCredentials 
    { 
     get { return null; } 
    } 

    public override string ToString() 
    { 
     return String.Format("WindowsIdentity: {0} ({1})", this.ImpersonationUser.Name, this.ImpersonationUser.User.Value); 
    } 
} 

अन्य चीजें आप को पता है की आवश्यकता हो सकती ...

  • यह किसी इंट्रानेट पर प्रतिरूपण चल रहा है, और चालू है।
  • लॉगिंग इंगित करता है कि प्रतिरूपण उपयोगकर्ता सही ढंग से सेट किया जा रहा है।
  • यह काम करता है जब दृश्य स्टूडियो (http://localhost:devport) में चल रहा है, और यह काम करता है जब मेरे विकास बॉक्स (http://localhost/myApplication) पर चल रहा है। यह हमारे परीक्षण या उत्पादन सर्वर पर चलते समय काम नहीं करता है।
  • मैंने web.config में system.net.defaultProxy सेटिंग्स के साथ और बिना दोनों समाधानों का प्रयास किया है। न तो काम किया।

मैं क्या गलत कर रहा हूं? क्या यह एक सर्वर सेटिंग है? क्या यह कोड है? क्या यह web.config है?

+0

प्रतिरूपण उपयोगकर्ता रिपोर्ट सर्वर तक पहुँच है - विशेष रूप से उस रिपोर्ट? – NYSystemsAnalyst

+0

क्या आपने अपने डीवी मशीन (लोकलहोस्ट) पर प्रतिरूपण उपयोगकर्ता के तहत आईआईएस चलाने का प्रयास किया है ताकि आपके परीक्षण सर्वर पर क्या हो रहा है? यह रिपोर्टिंग सर्वर या रिपोर्टिंग सर्वर डेटाबेस के विरुद्ध आपके प्रतिरूपण उपयोगकर्ता के साथ एक फ्लैट आउट अनुमतियों की तरह लगता है। मुझे लगता है कि प्रतिरूपण उपयोगकर्ता एक डोमेन खाता है। –

+0

@NYSystems विश्लेषक - हां, प्रतिरूपण उपयोगकर्ता को रिपोर्ट सर्वर पर उपयुक्त निर्देशिका तक पहुंच है। –

उत्तर

5

हमने आखिरकार समस्या को समझ लिया। हमारे नेटवर्क प्रशासकों ने डबल-होपिंग को अक्षम कर दिया है, इसलिए प्रतिरूपण domain\jmeyer के रूप में सही ढंग से कनेक्ट हो रहा था, फिर भी एप्लिकेशन domain\web01$ के साथ एसआरएस बॉक्स से कनेक्ट करने का प्रयास कर रहा था। यह इस तरह क्यों स्थापित किया गया है? क्योंकि डबल-होपिंग एक विशाल सुरक्षा छेद है। (या तो मुझे बताया गया था। कुछ की तरह इस ध्वनि आप The Daily WTF पर पढ़ा होगा करता है?)

हमारे समाधान एक सामान्य domain\ssrs_report_services उपयोगकर्ता बनाते हैं, और निम्न नेटवर्क पहचान के साथ यह है कि उपयोगकर्ता के साथ कनेक्ट करने के लिए था

public class CustomCredentials : IReportServerCredentials 
{ 
    public bool GetFormsCredentials(out Cookie authCookie, out string userName, out string password, out string authority) 
    { 
     authCookie = null; 
     userName = password = authority = null; 
     return false; 
    } 

    public WindowsIdentity ImpersonationUser 
    { 
     get { return null; } 
    } 

    public ICredentials NetworkCredentials 
    { 
     get { return new NetworkCredential("ssrs_report_services", "password", "domain") ; } 
    }  
} 

उपरोक्त क्लासिक उदाहरण समाधान है जिसे आप सभी internets पर पा सकते हैं।

+0

वास्तव में, मुझे नहीं लगता कि किसी भी कॉन्फ़िगरेशन के तहत डबल होपिंग "अनुमति" है। यह मुझे स्पष्ट नहीं है कि आपका देव पर्यावरण क्यों काम कर रहा था, लेकिन शायद यह अलग-अलग कॉन्फ़िगर किया गया था। –

+0

जैसा कि यह मुझे समझाया गया था, यह देव पर काम करता है क्योंकि यह स्थानीयहोस्ट (क्लाइंट के रूप में) -> लोकहोस्ट (आईआईएस के रूप में) -> एसआरएस –

+0

एफवाईआई से जाने की उम्मीद के रूप में नहीं गिना जाता है, व्यवस्थापक प्रति प्रतिनिधि प्रतिनिधि को कॉन्फ़िगर कर सकते हैं सर्वर के आधार पर। जांचें: http://serverfault.com/questions/16364/is-there-a-way-to-get-kerberos-credentials-to-delegate-twice-why-not –

2

"डबल होपिंग" अनुमति दी है - swith Kerberos प्रमाणीकरण पर ... (जब तक कि यह ठीक से काम कर रहा है!)

+1

दुर्भाग्यवश, हम डेवलपर्स पर्यावरण से काफी परेशान हैं और बुनियादी ढांचे में कोई बात नहीं है। हालांकि, मुझे पढ़ने के लिए कुछ नया देने के लिए धन्यवाद। –

संबंधित मुद्दे