views:

296

answers:

1

I recently began writing an AJAX web part for use in SharePoint and I am having a strange error. It seems that EnsurePanelFix() is causing the web part to throw a 401 error; in the log, both 401.2 and 401.3 errors are showing up right around the same time. I made some changes to EnsurePanelFix() after doing a bit of research on here and some other sites, and it is currently as follows:

void EnsurePanelFix
{
            // Change AJAX doPostBack behavior to fix the update panel.
            if (this.Page.Form != null)
            {
                String fixupScript = @"
                                     if (typeof(_spBodyOnLoadFunctionNames) !== 'undefined'){
                                     _spBodyOnLoadFunctionNames.push(""_initFormActionAjax"");
                                     function _initFormActionAjax() {
                                     if (_spEscapedFormAction == document.forms[0].action){
                                     document.forms[0]._initialAction =
                                     document.forms[0].action;
                                     }
                                     }

                                     RestoreToOriginalFormAction = function() {
                                     if (_spOriginalFormAction != null) {
                                     if (_spEscapedFormAction==document.forms[0].action){
                                     document.forms[0].action=_spOriginalFormAction;
                                     }
                                     _spOriginalFormAction=null;
                                     _spEscapedFormAction=null;

                                     document.forms[0]._initialAction = document.forms[0].action;
                                     }
                                     };
                                     }";

                string scriptKey = "UpdatePanelFixup";
                if (!Page.ClientScript.IsClientScriptBlockRegistered(scriptKey))
                    ScriptManager.RegisterStartupScript(this, typeof(SpecDatabaseViewer), scriptKey, fixupScript, true);

                ScriptManager.RegisterStartupScript(this,
                  typeof(SpecDatabaseViewer), "UpdatePanelFixup",
                  fixupScript, true);
            }

Watching the security log, I see that the failures are logged as such:

Event Type: Failure Audit
Event Source:   Security
Event Category: Object Access 
Event ID:            560
Date:       1/6/2010
Time:       11:46:34 AM
User:       NT AUTHORITY\NETWORK SERVICE
Computer:   SHAREPOINT
Description:
Object Open:
    Object Server:  SC Manager
    Object Type:    SERVICE OBJECT
    Object Name:    WinHttpAutoProxySvc
    Handle ID:  -
    Operation ID:   {0,69477107}
    Process ID: 404
    Image File Name:    C:\WINDOWS\system32\services.exe
    Primary User Name:  SHAREPOINT$
    Primary Domain: SPDOMAIN
    Primary Logon ID:   (0x0,0x3E7)
    Client User Name:   NETWORK SERVICE
    Client Domain:  NT AUTHORITY
    Client Logon ID:    (0x0,0x3E4)
    Accesses:   Query status of service 
            Start the service 
            Query information from service 

    Privileges: -
    Restricted Sid Count:   0
    Access Mask:    0x94

There are multiple failure audits with the only differing data between them being the operation ID.

Can anyone see any reason that I would be having authentication or file permission problems given that everything works fine without this piece of code? Thanks.

EDIT: I'm pretty sure that it has something to do with the ACLs, but I'm not exactly sure where to look for what resources may be causing the issue.

A: 

Can you catch, what URL exactly generates the 401.x errors? Must be visible if you intercept calls with Fiddler.

Also, this description seems very similar to your case: http://forums.asp.net/t/1187045.aspx

naivists
Also, I did happen to stumble across that forum post as well - David Wang's article is what led me to check the log for the substatus code. Unfortunately, it didn't help me fix the problem.
Geo Ego
Fiddler is showing that the url is http://sharepoint:15741/_layouts/WPPrevw.aspx?ID=233 if I attempt to preview the web part. If I attempt to add the web part to a page, I get a 503 (service unavailable) error, and then even previewing the web part will give me a 503 until I reset IIS.
Geo Ego
is there REALLY a slash symbol at the end of the url after "233" or that's just StackOverflow? If yes, then - there you have the answer
naivists
No, that's just StackOverflow's comment formatting. Although had that been the problem, I could have just smacked my forehead and moved on. :)
Geo Ego
Also, I edited the question to say this, but just to throw it out there, I'm pretty sure it's got something to with ACL entries for resources that are being accessed by EnsurePanelFix(). I'm not sure exactly how to troubleshoot that, though, especially considering that my development user has Full Control for everything.
Geo Ego
A stupid question - have you configured SharePoint (service pack installed, web.config changes, asp.net ajax toolkit et cetera) correctly? Do other ajax webparts work in your farm? Here is a good walkthrough to get it working: http://jamestsai.net/Blog/post/How-To-Create-AJAX-enabled-SharePoint-Web-Part-with-UpdatePanel-and-UpdateProgress-in-10-minutes.aspx
naivists