Visual Studio 2012: can't connect to sharepoint site - visual-studio-2012

I'm trying to create a simple webpart using Visual Studio 2012 but when I try to validate my Sharepoint Server it says:
Cannot connect to the SharePoint site: "url" 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.
i have SharePoint 2013 installed on my local machine and I can browse the site.
I tried this solution (resolving-vs-2010-solution-deployment-issues-for-sharepoint-2010-projects) and added my user as in mentioned DBs. For confirmation i ran executed the query :
Add-SPShellAdmin -UserName domain\username
and the result was :
"Cannot add dcci\User2 to the SharePoint_Shell_Access role of the database SharePoint_Config. A possible cause of this error is that the account name was already added to the database as a login using a different user name than the account name."
Secondly, I have configured the Alternate access mapping for my site, it is running on port 91 for one zone and on default 80 other. I have tried both the URLs to validate the result. below is the detail from event viewer.
RegOpenKeyExW(-2147483646,SYSTEM\CurrentControlSet\Services\VSS\Diag,...)
0x80070005, Access is denied.
Operation: Initializing Writer Context: Writer Class Id: {0ff1ce15-0201-0000-0000-000000000000} Writer Name: OSearch15 VSS Writer Writer Instance Name: OSearch15 Replication Service Writer Instance ID: {e8767b85-1452-4bd1-8091-6fe8ed6fd8ce}
Any help would be really appreciated.

Verify that your Login is in the db_owner group on the SQL Instance.
Follow this guide step by step and verify each step is true: Account Permissions and Security Settings in SharePoint 2013. This one is more detailed and maybe a little overboard for what you need, but it is the long path for access rights. Refer to #2 for a simpler path.
Another good simple guide: Prepare your SharePoint 2013 farm for App development and debugging. This Guide fixed most of my local development needs.

Related

Sharepoint 2013 connecting to TFS 2013 - Error with Excel reports

We have upgraded TFS 2012 to TFS 2013 and did not have sharepoint installed before. So i installed tfs sharepoint components on a sharepoint server and tfs server and connected them. Everything is fine except excel reports and they give me the following error:
External Data Refresh Failed
The data connection uses Windows Authentication and user credentials could not be delegated. The following connections failed to refresh: TfsOlapReport
i have made sure Claims to windows authentication service is running.
To fix the error, please follow steps below which are quoted from this blog.
On the Team Foundation Server Administration Console, click Extensions for Sharepoint Products.
Select the Sharepoint Web Application which you are using.
Click Modify Access
Enter a user with access rights to the reports inside the Enterprise Application Definition field
Browse to Central Administration in Sharepoint
Select Manage Service Applications
Select Secure Store Service (Type: Secure Store Service Application)
Under Manage Target Applications, Click on New
Enter Target Application ID = "TFS", Display Name = "TFS", Contact Email="Whatever", Target Application Type = "Group", Target Application Page URL = "None" and click Next
Do not enter anything on this page as it's asking for fields name and not the actual credentials.
Enter Target Application Administrators and Members and click ok.
it will take you back to the page that was displayed after performed step 3.
Now right click on "TFS" and select "Set Credentials" and then enter the username and password that this account will be running under.
Now login to the TFS Server and click extensions for Sharepoint products.
Select the sharepoint web application you are using.
Click Modify access.
Enter "TFS" under the Enterprise Application Definition field.
Also just to make sure "Excel Service applications are configured properly, Click on "Excel Service Application "Type: Excel Services Application Web Service Application".
Click on Trusted File Location and make sure the site collection is added to the Trusted File Location and location type is "Microsoft Sharepoint foundation". under Trust children check "children trusted". under Allow external data select "Trusted data connection libraries and embedded".
Go back to page displayed after step 14 and select "Global Settings".
File access method = "impersonation", Under Analysis Services EffectiveUserName, check "Use the EffectiveUserName property".
Check "Use an existing Unattended Service account" radio button and under Target Application ID: enter "TFS".
Also make sure under Trusted Data Providers, the providerid your excel application is using is listed.

SPAppToken (context token) is null

I have a Sharepoint 2013 on premise environment for which I am developing an provider hosted app using Visual Studio.
The Visual Studio project has an app project which contains a custom ribbon button that goes to the web project. The web project is hosted on Windows Azure and here I get the error that the context token is null or an empty string.
Getting the token is done using the following code:
var contextTokenString = TokenHelper.GetContextTokenFromRequest(Request);
SharePointContextToken contextToken =
TokenHelper.ReadAndValidateContextToken
(contextTokenString, Request.Url.Authority);
When I see what is passed to the site hosted on Azure I notice that the SPAppToken is null. When using ULS viewer I get the error "The Azure Access Control service is unavailable"
I have already checked if the app is registered (using appregnew.aspx) and that the id is the same for this and in the appManifest.xml and web.config files.
How do I get the context token? Do I need to do something else in Azure in order to make it work?
The link from the comments helped me. I'm posting the answer here so we don't need to rely on a url sticking around.
You get the "EndpointAuthorityDoesNotMatch" message when your app's launch url doesn't match the "app domain" registered for your app's client_id.
For mine this meant that I needed to re-register the app for our test server separately from our develoment server via the _layouts/15/appregnew.aspx page on the O365 site. Here's a link with more info on registering client ids: http://msdn.microsoft.com/en-us/library/jj687469.aspx
Message 'The Azure Access Control service is unavailable' says that SharePoint can’t construct the SPAppToken because it can’t talk to ACS (Azure Access Control) in order to do that. This could be for a variety of reasons (e.g. network connectivity problems).
You can also check this blog: CJG: The Azure Access Control service is unavailable.

Sharepoint Webpart

I have created a webpart which works fantastic on my Virtual Machine where I have developed it.
But When I try to run the same webpart on my physical Machine, I cannot open the SQL Connection as the SQL Server is Seperate box on the network.
My Physical, Virtual and SQL Box are on the Same network but for some reason, It doesn't work on my Physical Machine,
It Come up with the following Message: Login failed for user 'NT AUTHORITY\ANONYMOUS LOGON'
What causes this Issue?
You are using Intgrated Security, which means the current User is used for authentication against the database service. On the production server the webpart code is executed, using the anonymous user. And (of course) this user has no right to access any ressources other the web server files.
To avoid this behaviour use a dedicated account using SQL-Server security. See this example Connection string:
connectionString="Data Source=SERVERHOSTNAME;Initial Catalog=YOURDATABASE;Persist Security Info=True;User ID=YOURUSER;Password=YOURPASSWORD";
Be sure to get a valid logon from your production database administrator for your database with appropriate rights (such as db_reader).
You specified User Id and Password and then set Trusted_Connection to True, so I guess that integrated authentication is used - remove the Trusted_Connection=True part.

programmatically access sharepoint lists using impersonation

I building a console app that runs under a normal user account to access sharepoint lists programmatically. In order to access Sharepoint objects the console application impersonates the user under the context of which the Sharepoint is running. The impersonation is successful but when I try to access any share point SPWeb objects the following error is given as follows
spWeb.ID = 'spWeb.ID' threw an exception of type 'System.Data.SqlClient.SqlException'
base {System.Data.Common.DbException} = {"Cannot open database \"WSS_Content_92\" requested by the login. The login failed.\r\nLogin failed for user 'DOM\USER'."}
Doesnt the imepersonation should have allowed to access to the underlying database and also do i need to explicitly grant access to the current user to give access to sharepoint lists etc.
Thanks in advance
In a console or windows app when accessing the object model - when you are impersonating the user then the database connection will be made under the users account credentials - so in effect you will have to give each of your users fairly high level permissions to access the database (or better make them a member of a group that has these permissions).
http://technet.microsoft.com/en-us/library/cc721638(office.12).aspx
This is different to the web app where the account used is the AppDomain account of the IIS site.
However - this is a very non-standard setup and is fraught with security risks - do you really want to give your users permission to access that database directly?
Instead can I suggest that you look again at your design - what are you trying to achieve?
Running the console application in the context of the same user as the application pool did the trick. So the solution would be to use the runas command.

Sharepoint Site Administration

I've got a SharePoint website running on my machine (which it shows me inside the Application Pool in the Inet Manager).
Now this website has a different user credentials specified under the Identity section (properties). Also when I view the w3wp.exe in the task manager it shows that the site is running as a different user.
The problem is that if I change the username and password of the existing user with mine, the site stops working.
How do I run it under my account credentials.
Please help. Thanks
If you want to change the account that runs the SharePoint application pool, you must make sure that the new account has the same permissions as the current one. That includes the correct database permissions. Otherwise the SharePoint Web Application stops working.
The behavior you are describing is normal. Whatever account you use to login to your SharePoint site, the application pool will still be using the account assigned to it.
Regards,
M

Resources