none
Error 401 Unauthorized bei Zugriff via Listservice RRS feed

  • Frage

  • Hallo,

    ich möchte aus einer ASPX-Seite auf eine Liste via Webservice zugreifen und Werte reinschreiben... Leider bekomme ich folgende Fehlermeldung:

    Event Type:    Warning
    Event Source:    ASP.NET 2.0.50727.0
    Event Category:    Web Event
    Event ID:    1309
    Date:        29.10.2009
    Time:        11:17:07
    User:        N/A
    Computer:    VV0013
    Description:
    Event code: 3005
    Event message: An unhandled exception has occurred.
    Event time: 29.10.2009 11:17:07
    Event time (UTC): 29.10.2009 10:17:07
    Event ID: 45eb67c8dba24d2993596212957082d0
    Event sequence: 192
    Event occurrence: 15
    Event detail code: 0
     
    Application information:
        Application domain: /LM/W3SVC/271476794/Root-5-129012126616692757
        Trust level: Full
        Application Virtual Path: /
        Application Path: C:\Inetpub\wwwroot\eforms\
        Machine name: VV0013
     
    Process information:
        Process ID: 10236
        Process name: w3wp.exe
        Account name: NT AUTHORITY\NETWORK SERVICE
     
    Exception information:
        Exception type: WebException
        Exception message: The request failed with HTTP status 401: Unauthorized.
     
    Request information:
        Request URL: http://eforms/IT/Requirement/ConfirmRequirement.aspx?Requirement=152
        Request path: /IT/Requirement/ConfirmRequirement.aspx
        User host address: x.x.x.x
        User: Domain\user
        Is authenticated: True
        Authentication Type: Negotiate
        Thread account name: Domain\sqlwebaccess
     
    Thread information:
        Thread ID: 1
        Thread account name: Domain\sqlwebaccess
        Is impersonating: False
        Stack trace:    at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall)
       at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)
       at WSListItPurchase.Lists.UpdateListItems(String listName, XmlNode updates) in c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\f9d248cf\b05a8941\App_WebReferences.2ggytsgh.0.cs:line 667
       at IT_Requirement_ConfirmRequirement.CreateEntryInItWorkspacePurchaseList(String RequirementId, String Projekt) in c:\Inetpub\wwwroot\eforms\IT\Requirement\ConfirmRequirement.aspx.cs:line 279
       at IT_Requirement_ConfirmRequirement.LinkButtonApproveRequirement_Click(Object sender, EventArgs e) in c:\Inetpub\wwwroot\eforms\IT\Requirement\ConfirmRequirement.aspx.cs:line 131
       at System.Web.UI.WebControls.LinkButton.OnClick(EventArgs e)
       at System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument)
       at System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
       at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
       at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
       at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
     
     
    Custom event details:

    For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp.

    Der Code für den Zugriff sieht aus wie folgt:

    //Festlegung Zugriffskonto
    
            System.Net.NetworkCredential MyCredential = new
     System.Net.NetworkCredential("writeraccount"
    , "123456"
    , "domain.com"
    );
    
    //ListService Initialisieren
    
            WSListItPurchase.Lists listService = new
     WSListItPurchase.Lists();
            listService.Credentials = MyCredential;
            listService.Url = "http://www/it/purchase/_vti_bin/lists.asmx"
    ;
    
    //Variablen festlegen
    
            string
     Artikel = ""
    ;
            string
     Quantity = ""
    ;
            string
     Department = ""
    ;
            string
     PriceString = "255,00"
    ;
            decimal
     PriceInt = Convert.ToDecimal(PriceString);
    
    //XML-Batch festlegen
    
                            string
     strBatch =
                                "<Method ID='1' Cmd='New'>"
     +
                                    "<Field Name='ID'>New</Field>"
     +
                                    "<Field Name='Title'>"
     + Artikel + "</Field>"
     + //Artikel
    
                                    "<Field Name='Requirement_x0020_ID'>"
     + RequirementId + "</Field>"
     + //Requirement ID
    
                                    "<Field Name='Datum_x0020_Approval'>"
     + DateTime.Now.ToString("u"
    ) + "</Field>"
     + //Datum Approval
    
                                    "<Field Name='Projekt'>"
     + Projekt + "</Field>"
     + //Projekt
    
                                    "<Field Name='Qty'>"
     + Quantity + "</Field>"
     + //Quantity
    
                                    "<Field Name='Department'>"
     + Department + "</Field>"
     + //Department
    
                                    "<Field Name='Order_x0020_Form'>"
     + OrderForm + "</Field>"
     + //Order Form
    
                                    "<Field Name='Preis_x0020_SOLL'>"
     + PriceString + "</Field>"
     + //Gesamtpreis: Qty*Einzelpreis
    
                                    "<Field Name='LinkRequirement'>http://eforms/IT/Requirement/admin/QueryRequirements.aspx?ID="
     + RequirementId + "</Field>"
     + //URL zu Requirement
    
                                    "<Field Name='Bemerkungen'>Eingefügt via eForm IT Requirement</Field>"
     + //Kommentar
    
                                "</Method>"
    ;
                            XmlDocument xmlDoc = new
     XmlDocument();
                            XmlElement elBatch = xmlDoc.CreateElement("Batch"
    );
                            elBatch.SetAttribute("OnError"
    , "Return"
    );
                            elBatch.SetAttribute("ListVersion"
    , "1"
    );
                            elBatch.InnerXml = strBatch;
    
                            //Liste "Purchases/Orders"
    
                            XmlNode ndReturn = listService.UpdateListItems("{5D734CE7-DCE9-4D10-9AC1-7AC12B2DD1E3}"
    , elBatch);
    
    
    Hat jemand eine Idee?

    Mir ist auch aufgefallen, dass ich zwar für den Zugriff auf die Liste einen Account festgelegt habe, dieser aber im Errorlog nicht auftaucht, statt dessen der Service Account für den SQL-Zugriff verwendet wird.
    Donnerstag, 29. Oktober 2009 11:31

Antworten

  • Ok, hab's gefunden und mein Kopf hat mehrfach Bekanntschaft mit der Tischplatte gehabt... Der User, den wir für den Zugriff verwenden hat keine Rechte in der Liste gehabt..
    Donnerstag, 29. Oktober 2009 12:52