Skip to content

Encountering a 403 Forbidden exception consistently #682

@lohith1024

Description

@lohith1024

Question

I'm using SharePoint 2016 on-premises, and I've been successfully connecting to the SharePoint server using the following code with my own credentials. This means that my Active Directory account is verified, allowing me to access SharePoint and perform various operations on the server.

Now, I need to use a service account to connect to SharePoint, which requires passing the service account's username and password. To test this configuration, I've disabled my default login account to ensure that I'm using the service account.

However, when attempting to connect to SharePoint with the service account, I'm encountering a 403 Forbidden exception consistently. It's important to note that the service account has been granted administrative privileges on this SharePoint instance.

Here's the code snippet I'm using for authentication:
OfficeDevPnP.Core.AuthenticationManager authenticationManager = new OfficeDevPnP.Core.AuthenticationManager();
var clientContext = authenticationManager.GetWebLoginClientContext(siteUrl);

Despite granting admin privileges to the service account, this code is resulting in a 403 Forbidden error.

i got my access removed and using service account, i get this error
AADSTS50105: Your administrator has configured the application SharePoint on-premises ddddd ('2342-234234-4d1b-899b-7ab3f6ee30e9') to block users unless they are specifically granted ('assigned') access to the application. The signed in user 'abc@abc.com' is blocked because they are not a direct member of a group with access, nor had access directly assigned by an administrator. Please contact your administrator to assign access to this application.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions