Cannot connect to the Sharepoint Site from Visual Studio 2010 - c#

I'm new to Sharepoint. I'm trying to create a simple webpart using Visual Studio 2010 but when I try to validate my Sharepoint Server (both VS 2010 and Sharepoint are present in the same system) it says:
Cannot connect to the SharePoint site: http://wpnne76648:2010. Make sure that the Site URL is valid, that the SharePoint site is running on the local computer, and that the current user as the necessary permissions to access the site.
If I ignore this and click finish and then try to deploy the application it says:
Error occurred in deployment step 'Recycle IIS Application Pool': The local SharePoint server is not available. Check that the server is running and connected to the SharePoint farm.
Note: I can open my web application in the browser.

Ref: 2
This issue can be fixed by doing the following :-
Added myself as the administrator
Added myself to SharePoint Farm Admin Group
Provided DB Owner access to SharePoint Content DB

I've tried the below steps and it solved my issue. using Sharepoint Power Shell to grant my user the privileges to Content Databases.
Add-SPShellAdmin -UserName domain\username This will add permissions to the config database in SharePoint 2010
Get-SPContentDatabase -WebApplication This will return information on the content database for the desired web application
Add-SPShellAdmin -UserName domain\username -database This will add permissions to the content database for the desired web application
UPDATE
I've also found that SQL Server Agent(SHAREPOINT) Service was disables, enabling it solved my issue one more time.

Have you tried to create a new site collection and connecting to that one? Take into account that merely creating the web application isnt enough, the site collection needs to be there as well.

$db = Get-SPContentDatabase -WebApplication http://mycompany.corp/
Add-SPShellAdmin -UserName domainName\username -database $db.Id

OK, if you have a local SharePoint Farm, you may have to create an AAM pointing to the default URL.
For example, I created a Web App: http://portaldev10.jedi.local but VS defaulted to http://DEV2010 and nothing I could do could get it to resolve the DNS URL... so I created an Internal AAM and VS works.
Crazy... I know

Probably this step will help you.
I tried all the possible solutions with Active Directory, IIS Authentication and finally was able to fix the issue just by doing the below. Hope this will help you in similar kind of issue.
1.Do a IIS reset
2.Check if IIS is resetting.
3.If it is not, then disable UAC from control panel and IIS reset will work.
4.Go to Central Administration site
5.Navigate to the Manage Web Applications page
6.Click on the web application that hosts the site you are trying to deploy
7.Click the User Policy ribbon item.
8.Add your windows account to the list of users with the Full Control permission.
Good Luck

Related

Append or Inject domain into Username when logging into sharepoint 2013

I have set up SharePoint 2013 for my organization but the users have to always enter a domain (User1#domain.com) after their username.
I have searched but i cant find any solution or even where the file for this is located. I'm wondering if i can get some help either finding where that file is or an alternate solution for this issue. Thanks!
Switching my authentication type is not really an option either, and yes I want the user to be promoted for the password every time.
On the SharePoint server I went to IIS, clicked on the local host tree then in the center console under IIS I opened up Authentication. Click basic authentication then under actions click edit. Once there I entered a default domain name and voila, like magic it now works!
So if i understand correctly here your SharePoint farm domain (e.g. sharepoint.com) and users domain (user#companyXYZ) don't have a "trust relationship?.
When you access a office document from a library as an Untrusted Client (even though your login credentials are already authenticated by the browser session cookie) when an Office Application opens, IE does not pass authentication/trust/token to the next application to gain the same access that is already trusted with IE. The additional log-in prompts is because the documents opened with Office are trying to re-establish a trust per application, because the client machine is not trusted from a public web and a new authentication is requested.
May want to review : Authentication prompts when opening Microsoft Office documents
If you can provide a fiddler trace of an authentication and identify if you are using "classic" or "claims" i can help more.

Access to the path is denied

I am currently creating a folder and writing a file to the folder that need to be create on a file server that we have. When i do a localhost test, it work perfectly but when i access the website from outside the localhost and from another pc. It said that
System.UnauthorizedAccessException: Access to the path 'My File Server
URL' is denied
ASP.NET is not authorized to access the requested resource. Consider
granting access rights to the resource to the ASP.NET request
identity. ASP.NET has a base process identity (typically
{MACHINE}\ASPNET on IIS 5 or Network Service on IIS 6) that is used if
the application is not impersonating. If the application is
impersonating via , the identity will be
the anonymous user (typically IUSR_MACHINENAME) or the authenticated
request user.
To grant ASP.NET access to a file, right-click the file in Explorer,
choose "Properties" and select the Security tab. Click "Add" to add
the appropriate user or group. Highlight the ASP.NET account, and
check the boxes for the desired access.
But the thing is that i have already set the identity impersonate="true" in the web.config and it still didn't work. My web server is running on Winder Server 2003 and IIS 6
Any advice and help will be deeply appreciated
Thanks
Brandon
You need to grant write, modify permission to the Users group for that file/folder.
Check your IIS Authentication setting and make sure that Anonymous authentication is enabled.
Hi Guys i manage to find the solution to it
If u are creating a folder, using this code before file or folder creation
WindowsImpersonationContext ctx = WindowsIdentity.Impersonate(IntPtr.Zero);
// Insert the create code here
ctx.Undo();
Well i do not know if this is the best solution. if anyone know the downside or implication of this code please share and comment.
no harm knowing more

Programmatically create SharePoint list

I downloaded a plugin for an Office product that prompts you for your SharePoint site url and username and password and then it will create you appropriate lists and views on your SharePoint site. Can someone let me know if I can make a program on my Windows XP machine that will take in the site url, username and password and be able to programmatically create lists and views?
I did some searching on google and it seems this needs to be done on the SharePoint server. I don't have access to the server and would need to do the development from my XP machine. And seeing the plugin do exactly what I wanted gives me some hope.
Thanks.
You'll want to look at accessing SharePoint through its Web Services. Specifically, the Lists Web Service and the Views Web Service. Here's the Lists.AddList method from the lists service - should get you going down the right path.

How to specify guest access to C#/SQL internet site?

I just created a website in ASP.NET and C# and am hosting it now at this URL below. This URL is working now:
http://96.0.101.66/Default.aspx
However, currently this website does not list the SQL tables, which should be on the left-hand side of this window in a gridview. I think this is because I disabled anonymous access from IIS6 Manager. (I'm using IIS6 Manager on an XP OS). I disabled this cause I also have SQL Server 2008 on same machine. Same machine for hosting website, developing VS 2008 C# code, and SS 2008 database.
However, I see this gridview when I Browse my IIS6 Manager. So this webpage is working on my computer, just not from the internet.
Which user should I configure to access this website and how? Like should I choose ASPNET account? They should be able to append data to existing Adventureworks tables. They choose which table to append from this URL above.
Also, do I need to upload any MDF files from Adventureworks? I don't think so cause they should be able to access the Adventureworks database on my computer, right?
I checked Event Viewer and am getting the following Failure Audit:
Login failed for user 'NT
AUTHORITY\NETWORK SERVICE'. Reason:
Failed to open the explicitly
specified database. [CLIENT: ]
I'm new to IIS and C#, so any help is much appreciated!
Oh dear; please remove that website immediately, it's returning all your pages as it's probably not configured to run IIS. I'd stop that site being public ASAP.

Accessing a remote file with a SharePoint Web Part

I recently built a program that parses a remote file from \some_server\c$\directory\file.xls and it works fine on my local machine as just a normal aspx page.
Then I put the program into web part
form on my VM SharePoint server and I
get this error: Access to the path
'\some_server\c$\directory\file.xls'
is denied.
The file is shared to Domain\Authenticated Users so I am not sure why it would be denied? Is it possible my SharePoint is trying to call it with a local or network service account? How can I get it to read? Thank you.
Salamander is right, SharePoint doesn't run with trust to do this.
Changing the trust level for SharePoint in it's web.config from WSS_Medium to Full is the quick solution, but there are security implications..
Just a quick note, you could be running into the classic NTLM Double-Hop issue. You can authenticate to the front end, but because the front end does not have your password, it cannot then authenticate to a resource on another server.
Running with Elevated priviliges, and setting permissions based on the Application Pool identity could be one way of moving your forward.
I think you will need RunWithElevatedPrivleges which will make SharePoint use the application pool account. Also keep in mind you will have to make sure that application pool account has access to that network share. Avoid using full trust.
Can you explain further what exactly setting the trust level does for you?
I would think that if your app pool identity is a domain account you can use SPSecurity.RunWithElevatedPrivileges to use the app pool credentials to access the file. Or, use impersonate to explicitly pass another account's credentials.
SharePoint usually runs in a separate application pool. Please check the identity of this application pool.
I think to be able to access network path, your code has to run in FULL TRUST, which I don't think SharePoint does.
Why not store the file in SharePoint so you have better access to it? Put it in a hidden library and access it using SPSecurity.RunWithElevatedPrivledges.
There are caveats to RWEP. Any reference to SPSite and SPWeb obtained from the SPContext (ie SPContext.Current.Site) will still run under the privledges of the logged on user. You must explicity create a reference inside the RWEP delegate.
SPSecurity.RunWithElevatedPrivileges(delegate()
{
using (SPSite site = new SPSite(SPContext.Current.Site.Url))
{
using (SPWeb web = site.OpenWeb())
{
//... Do something with SPWeb
}
}
});
If you need to access the file from outside sharepoint to update it with existing processes you can use the file share path which is available for all SPDocumentLibrary's but going to Actions --> Open with Windows Explorer to obtain the network path.

Categories

Resources