Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 83661
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T21:48:30+00:00 2026-05-10T21:48:30+00:00

This is a question for a WSS/SharePoint guru. Consider this scenario: I have an

  • 0

This is a question for a WSS/SharePoint guru.

Consider this scenario: I have an ASP.Net web service which links our corporate CRM system and WSS-based intranet together. What I am trying to do is provision a new WSS site collection whenever a new client is added to the CRM system. In order to make this work, I need to programmatically add the managed path to the new site collection. I know that this is possible via the Object Model, but when I try it in my own web service, it fails. Sample code extract below:

 Dim _ClientSiteUrl As String = 'http://myintranet/clients/sampleclient'          Using _RootWeb As SPSite = New SPSite('http://myintranet')              Dim _ManagedPaths As SPPrefixCollection = _RootWeb.WebApplication.Prefixes              If Not (_ManagedPaths.Contains(_ClientSiteUrl)) Then                  _ManagedPaths.Add(_ClientSiteUrl, SPPrefixType.ExplicitInclusion)              End If          End Using  

This code fails with a NullReferenceException on SPUtility.ValidateFormDigest(). Research suggested that this may be due to insufficient privileges, I tried running the code within an elevated privileges block using SPSecurity.RunWithElevatedPrivileges(AddressOf AddManagedPath), where AddManagedPath is a Sub procedure containing the above code sample.

This then fails with an InvalidOperationException, ‘Operation is not valid due to the current state of the object.’

Where am I going wrong?

One workaround I have managed to do is to call out to STSADM.EXE via Process.Start(), supplying the requisite parameters, and this works.

Update: whilst developing the web service, I am running it using the built-in Visual Studio 2005 web server – what security context will this be running under? Can I change the security context by putting entries in web.config?

Update: I think the problem is definitely to do with not running the web service within the correct SharePoint security context. I decided to go with the workaround I suggested and shell out to STSADM, although to do this, the application pool identity that the web service runs under must be a member of the SharePoint administrators.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T21:48:31+00:00Added an answer on May 10, 2026 at 9:48 pm

    Update I think you have proved that the issue is not with the code.

    SPSecurity.RunWithElevatedPrivileges: Normally the code in the SharePoint web application executes with the privileges of the user taking the action. The RunWithElevatedPrivileges runs the code in the context of the SharePoint web application pools account (i think) The description on MSDN could go into the details a tiny bit more.

    The issue with the call may be that the web service is not actually running the code within a SharePoint process, so explaining why it cannot elevate (wild guess alert).

    Have a crack at changing the user of your web services application pool and see if that gives any joy.


    It is likely to be a permissions issue. Maybe try:

    Dim clientSiteUrl As String = 'http://myintranet/clients/sampleclient' Using SPSite = new SPSite(clientSiteUrl)      webApp As SPWebApplication = SPWebApplication.Lookup(new Uri(clientSiteUrl));     If Not (webApp.Prefixes.Contains(clientSiteUrl)) Then         webApp.Prefixes.Add(clientSiteUrl, SPPrefixType.ExplicitInclusion)     End If End Using 

    This is not exact code.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 69k
  • Answers 69k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer Interfaces are useful when you want to mock an interaction… May 11, 2026 at 12:41 pm
  • added an answer As you've noticed DeepZoomComposer supports a <Tag></Tag> element which you… May 11, 2026 at 12:41 pm
  • added an answer Well the alert should go in the success callback and… May 11, 2026 at 12:41 pm

Related Questions

This is a question for anyone who has the pleasure to work in both
This is a perennial question for me that I've never really resolved so I'd
This question is for a web application. And maybe it's a stupid question but
I know that this is a simple question for PHP guys but I don't
To quickly summarise my question: Is it feasible to programmatically change the name of
I have a SharePoint (WSS 3.0, VS 2005) workflow that has a workflow modification
That's the title of kb947284 actually. Recently I was involved in a Sharepoint project.
First, let me use one sentence to let out some frustration: My god, developing

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.