Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have been newly assigned to a client and I am trying to run an existing console app to get some information about files within their sharepoint instance. The code goes something like this:

//Enter function
webURL = "http://mysite/mysub/";
using (SPSite site = new SPSite(webURL))
{
    using (SPWeb web = site.OpenWeb())
    {
        Console.WriteLine("Running");
        RunningFoo(web);
    }
 }
 Console.WriteLine("end");
 }//exit function

 private void RunningFoo(SPWeb web)
 {
        Console.WriteLine(web.Url.ToString());
        //do important stuff
 }

The output is:

Running
end

There is nothing wrong with the actual code or arguments supplied because the existing developer runs this with no problems. It is my suspicion that site.openWeb is returning a null object but I dont have access to the development tools to do debugging. Is there any way I can check to ensure my permissions (server-side and ecms login) are sufficient to do this? It is very possible that the server itself is blocking me from utilizing certain network services but it is also possible that my sharepoint permissions do not allow me to run custom code.

Any help is appreciated! Thanks

Update: I believe this may be an issue with permissions on the database server. I tried running an stsadm command the other day and received an access denied error on the database.

share|improve this question
    
Could you please post the full relevant code (genericizing as necessary) as the code above should be throwing all sorts of errors –  Dave Wise Aug 22 '12 at 16:56
    
What do you mean by check my permissions (server-side)? This code can ONLY run on the server. –  Per Jakobsen Aug 22 '12 at 18:57
    
This code is an .exe file on the wss hosting server. As I mentioned there is nothing wrong with the code. The point is after getting a SPWeb object the code stalls at printing the url within the web object. @Per Jakobsen basically I need to figure out if the server is letting me connect to the site (perhaps I may not have permission on a database or the server is blocking outgoing/incoming connections for my profile). I have already ensured I can access the files. Lastly, I am able to run this code successfully as a scheduled task running as another user. –  Realistic Aug 23 '12 at 21:41
add comment

2 Answers

up vote 0 down vote accepted

Turns out the stsadm command was the "Answer." The real issue was finding out whether or not I had database permission because the openWeb command has to query the database. To check whether or not you have permission to use SPWeb objects ask the database administrator or attempt to run an stsadm export or some other command that has to access the database. Originally I thought the database permissions were set by sharepoint server. Rookie mistake ^_^. I found this answer by reading http://stackoverflow.com/questions/3192966/programmatically-access-sharepoint-lists-using-impersonation

Tags: access denied using SPWeb object. Access denied on wss_content stsadm

share|improve this answer
add comment

As @per jakobsen said if your application run inside sharepoint site then you use object model but as you said you use console app that is not run code within your server.

so u need to use client-object-model

tell me your origin requirement and i provide u code for your console app

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.