Web Service returns HTTP status 401: Unauthorized
Web Service returns HTTP status 401: Unauthorized
Web Service returns HTTP status 401: Unauthorized
Web Service returns HTTP status 401: Unauthorized
Web Service returns HTTP status 401: Unauthorized
Web Service returns HTTP status 401: Unauthorized Web Service returns HTTP status 401: Unauthorized Web Service returns HTTP status 401: Unauthorized Web Service returns HTTP status 401: Unauthorized Web Service returns HTTP status 401: Unauthorized Web Service returns HTTP status 401: Unauthorized Web Service returns HTTP status 401: Unauthorized Web Service returns HTTP status 401: Unauthorized
Web Service returns HTTP status 401: Unauthorized Web Service returns HTTP status 401: Unauthorized
Web Service returns HTTP status 401: Unauthorized
Go Back  Xtreme Visual Basic Talk > > > Web Service returns HTTP status 401: Unauthorized


Reply
 
Thread Tools Display Modes
  #1  
Old 07-07-2008, 04:14 AM
mdent mdent is offline
Centurion
 
Join Date: Jun 2006
Location: Teesside, UK
Posts: 108
Default Web Service returns HTTP status 401: Unauthorized


Hi all. I have a function below which tries to access the a SharePoint 2003 web service with a given page and user. Unfortunately, I am getting "System.Net.WebException: The request failed with HTTP status 401: Unauthorized". I Know that both the credential cache im using and the url i am using for the service are both valid.

Code:
    Private Overloads Sub SetSecurityOnWeb(ByVal web As SPWeb, ByVal member As SPRole)
        Try
            Dim p As New myPermissions.Permissions
            Dim cc As New CredentialCache
            Dim myUrl As String = web.Url.ToString & "/_vti_bin/permissions.asmx"
            p.Url = myUrl

            cc.Add(New Uri(myUrl), "Basic", New NetworkCredential("[Admin]", "[AdminPassword]"))
            p.Credentials = cc

            p.AddPermission(web.Name, "Web", member.Name, "role", RightsMask)

            For Each subWeb As SPWeb In web.Webs
                SetSecurityOnWeb(subWeb, member)
            Next
        Catch ex As Exception
            WriteLog(ex.ToString, EventLogEntryType.Warning)
        End Try
    End Sub
Any ideas why I would get this error? I do not want to enable anonymous access.

Cheers.
__________________
"It compiles! Ship it!"
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Web Service returns HTTP status 401: Unauthorized
Web Service returns HTTP status 401: Unauthorized
Web Service returns HTTP status 401: Unauthorized Web Service returns HTTP status 401: Unauthorized
Web Service returns HTTP status 401: Unauthorized
Web Service returns HTTP status 401: Unauthorized
Web Service returns HTTP status 401: Unauthorized Web Service returns HTTP status 401: Unauthorized Web Service returns HTTP status 401: Unauthorized Web Service returns HTTP status 401: Unauthorized Web Service returns HTTP status 401: Unauthorized Web Service returns HTTP status 401: Unauthorized Web Service returns HTTP status 401: Unauthorized
Web Service returns HTTP status 401: Unauthorized
Web Service returns HTTP status 401: Unauthorized
 
Web Service returns HTTP status 401: Unauthorized
Web Service returns HTTP status 401: Unauthorized
 
-->