Programmatically create SharePoint list - c#

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.

Related

Create sharepoint user and log them in via c#

I have a public SaaS application. Users can signup and create and manipulate data records, etc. I also have a sharepoint server. I have an 'admin' user on the Sharepoint site. My SaaS app can log onto the Sharepoint server using the admin login and upload download files. That is all fairly straight forward.
What I want to be able to do is (1) programmatically create individual logins on Sharepoint for my SaaS users, (2) be able to log them in a serve them a links to sharepoints document so that they can 'live edit' them in Word. I want my app to be able to control which users can access and edit which documents.
The users are not all part of a single organisation, so I don't think I can use Active Directory. But I don't really know anything about Activie Directory, so that may not be true.
Does that make any sense? Is that even possible? I've done a lot of searching online but can't find anything that seems to achieve that. My alternative is to implement some sort of WebDav server, but having looked at that as an option, I think it makes more sense to try and integrate with the existing Sharepoint server.
Any help or pointers would be very gratefully received. Thanks.
Are you open to user Office 365. If yes, then think you should explore Microsoft Graph API. It allows you n number of options to connect the Microsoft 365 products including SharePoint Online and Identity/user management.

Is it possible to access windows username from outside domain?

I have a website deployed on a server with it's own domain. Is it possible to get the Windows username when that website is launched?
Say i have a website on foobar.com, when i access the site from any random windows desktop, i want to retrieve the windows username from client side.
I use this in code to access the username:
HttpContext.Current.Request.LogonUserIdentity.Name;
But this brings up a login prompt for the server that the website is residing, which doesn't help me. Even if i did log on to that server, it is still not getting the current user's windows username.
I have searched almost every post relating to this, but none are specific in this scenario.
IIS is setup to only windows auth. Any info on this is appreciated.
I have finally come to the conclusion that this is not possible. Instead went with integrating with Azure AD.

Issue reading lists from Sharepoint listdata.svc from another REST service

all.
I have created a REST ApiController that, among other things, attempts to call the /_vti_bin/listdata.svc of a Sharepoint site to get the contents of one or more Sharepoint lists.
The ApiController's web.config uses Windows authentication with no impersonation. In the code, I am using System.Net.CredentialCache.DefaultNetworkCredentials for the DataContext.Credentials.
When I run the service locally using Visual Studio, the ApiController is able to call the listdata.svc without any issue and is able to retrieve the full contents of the list(s).
However, when I deploy the ApiController to an actual IIS server that is running under a system account, the call to listdata.svc doesn't retrieve any results. From what I can see in my ApiController's logging, there are no exception beings thrown. According to the logs, the list(s) just appear empty (0 items).
I have checked to make sure the IIS system account has proper access to the Sharepoint site.
Any ideas about why the difference in behavior?
Figured out the issue. And the issue is kind of embarrassing considering the fact that I was a SharePoint Site Admin at one time.
I had forgotten that with SharePoint it is possible to have both site and list permissions for a given site that do not inherit from one another.
For whatever reason, this site had a set of permissions for the list I was trying to access that were different from the site in general.
The system account (s) used had site permissions of Full Control. But for the list in question, they had no permissions (but other accounts, like my own, did). This would explain why the system accounts could connect to the site's list service but the list appears empty.
After giving the system account (s) read permissions to the list, everything worked.
Lession here is: Just because an account has site permissions doesn't mean it applies to all lists in the site if the admin decides to permission the lists separately.
Hopefully, all of the above make sense.

How do I log into a web service that was auto-generated by Azure Mobile Web Services?

Microsoft's Azure Mobile Web Services lets you download a .NET or JavaScript Service and a client that talks to the Service. These are written in C#, or JavaScript. I chose to get one in C#. There is are several parts in the generated solution
A Windows 8.1 desktop client (yourname.Windows)
A windows mobile client (yourname.WindowsPhone)
A Azure Mobile Web Service (yournameService)
A shared .net assembly named (yourname.Shared)
You can right click on yournameService and click Publish and it takes you through a wizard which publishes your application directly from Visual Studio to an Azure server. At some point in the wizard it establishes automatically some rather complex credentials (because you have already logged into an Azure web subscription). Generally you can just click Next, Next, and get it published.
Now you have a webservice, which opens up in your web browser, but which requires you to log in. What I want to know is, how do you know the user name and password used for this login?
http://yourapp123.azure-mobile.net/help
Then you click "Try it out", and a web browser authentication dialog pops up.
Why is this a problem? So far as a user I have input:
My Visual Studio login credentials,
My connection to Azure (perhaps same, perhaps different as visual studio login)
During wizard I've determined login credentials to publish to Azure, using values I have no idea where they came from, and so I left them alone. These seem to be the only credentials I had any opportunity to enter, and any change from the defaults renders the wizard inoperable, so I'm sure that's not where I enter my user and password.
I created a username and password when I created the Mobile WebService, and these do NOT work when I try to log in.
Leave the user name blank. And put in your application key as password. You can find your application key from your Azure portal > Mobile service > manage keys.
The reason being is that AMS uses a Zumo header to decide proper authentication. Which is what the application key is used for. So it's making sure only people or applications which has the application key can access the web service. Hope this helps.

Cannot connect to the Sharepoint Site from Visual Studio 2010

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

Categories

Resources