Copying Content Types across SharePoint servers - sharepoint

I am developing a Windows application that will allow SharePoint administrators to copy a content type from one server to another (across two SharePoint environments). I am at a point where I have the content type information that I want to copy. However, I am not being able to connect to the destination server. I get a "FileNotFound" exception when I try to create a SPSite object using the destination site URL; my code base is on the source server.
My question: Does the SharePoint object model support connecting to a remote server? If not, can I create a content type object in the remote server using SharePoint web services? If not, is there any other alternative API (other than creating my own web service) to achieve this goal?
Thank you for you help in advance!

When talking about SharePoint 2010, you should have a look at the Content Type Hub. By using the Content Type Hub, you're able to easily share ContentTypes across SharePoint SiteCollections and WebApplications using the Metadata Service Application.
So you'll not have to copy the Content Type manually.

To answer your first question, no, the server object model can only used against the local environment.
The Webs web service ( http://msdn.microsoft.com/en-us/library/webs.webs_methods(v=office.12).aspx ) has provisions for creating/deleting/updating Content Types.
Keep in mind however that Content Types could theoretheticaly depend on externalities like workflows, event receivers, InfoPath forms, solutions and the like which will be harder/impossible to copy over to a new environment through the OOTB web services.

Related

SPFx to connect to local SQL Server Tables,Stored Procedures & view.. Approaches to follow

I am working on a migration from SharePoint 2010 to SharePoint Online. Where inside the on-premises the customer has a configurable Web Part (Server-side of course), which allow users to do the following:-
Specify a connection string to connect to on-premises SQL server
Specify the Table or Stored Procedure or View to connect with.
optionally to pass a Parameter to the Database.
After that the web part will show the results from the database and allow the users to filter the data which will be shown in a tabular format.
Here is a screenshot of the web part setting:-
Here is a screenshot of a result from one web part instance:-
So can we build similar web part using SPFx? If the answer is Yes, then is there an available 3rd party web part we can benefit from? Finally , i am also open to other approaches to achieve our work other than build/using SPFx web part.
Please note that I am already aware that i can create API for the DB and connect SharePoint Online to On-prem DB using gateways.. but my main question is; how we can develop a dynamic web part (similar to the current on-prem web part), which allow us to show & filter data from on-prem database's Tables,Views & Stored procedure, by just specifying which components (table,view or Stored Procedure) we want to show the data from .. Is there a documentation to create such SPFx web part? or if there are 3rd part SPFx web part that we can benefit from?
You have two possibilities to solve this challenge:
If you only have the possibility to refactor this Farm Solutions
Web Part to SPFx, consider using a local data gateway to
help as an artifact to generate the connections from the local
environment to the cloud, and suddenly, you can persist these
registered connections into a restricted access SharePoint List (for example) and consume with a combo box. But if you
can't make progress with this approach, you'll need to consider the
2nd possibility (this one is more difficult);
Develop a Provider-Hosted SharePoint Add-In, which can be hosted on on-premises IIS and can connect to your various on-premises databases as a shared connection string in your example image above.
I've using Microsoft Graph Connector to pull On-prem SQL data into Microsoft Search (via Microsoft API), and then combine that with PnP Modern Search for query/filter results by selecting Graph as data source.
This feature is listed under MS Search & Intelligence. You can
Specify a connection string to connect to on-premises SQL server
Specify the Table or Stored Procedure or View to connect with
-- You define it in the PnP <Modern Search web part. Note that you can only filter/query/refinable if you've defined it in step 1 or 2 above.

SharePoint as presentation layer for Azure SQL and Blob

We currently have a simple requirement to present our users with a table of records. Each record has link to a PDF stored within Azure storage. We need to have our users be able to click on a record and be able to view (in line) the associated PDF.
We currently use SharePoint Online and cannot store the data within SharePoint itself (organisational policy).
Is it possible to create a SharePoint site/web part etc to do the above? We are scoping out options.
Yes, SharePoint has several ways to do that.
Your best bet may be a custom list with a custom URL column for the link to the PDFs. Then you can insert a list web part on a page.
This approach works with modern pages and with classic pages.
If you use a classic interface, you could also create an out of the box links list, but that list type does not have a web part for the modern experience, so it will only work on classic pages.
SPFx webpart can be inserted into modern page or classic page.
And you could call AD-secured APIs(custom service) in SPFx, so you could create a custom service host in Azure and consume from SPFx webpart.
Connect to Azure AD-secured APIs in SharePoint Framework solutions

Display AD contact information in SharePoint list

Is there a way to link the Active Directory to a SharePoint list and pull metadata from AD into the SharePoint list?
E.g:
Pull name, role, Location from AD and store it in the list
It usually makes more sense to pull that information into SharePoint's user profile service than to push it into a SharePoint list.
However, the answer is yes. Here are two options:
Exposing Active Directory through an External Content Type
SharePoint 2010 introduced the concept of External Content Types (and External Lists that use those content types). An External Content Type pulls its information from a data source external to SharePoint instead of storing its data in a traditional SharePoint list, but it can be displayed within SharePoint in a manner consistent with SharePoint lists and libraries.
When you add an External Content type through SharePoint 2010, you can choose between three types of data sources: WCF Service (for web services), SQL Server (for a Microsoft SQL Server database), and .NET Type (for a .NET assembly connector or a custom .NET connector). Depending on your relative comfort level with SQL Server and .NET programming, you can either set up a SQL query view that looks at Active Directory or use C# to write a .NET connector that connects to Active Directory.
For more information on writing a .NET connector, refer to Microsoft's Documentation: Differences Between Using the .NET Assembly Connector and Writing a Custom Connector.
In SharePoint 2013 you can also create an external content type from any oData source. Again, this may entail writing your own wrapper code to expose Active Directory in a way that SharePoint can consume.
Pushing Active Directory Data into a SharePoint List
An external content type resembles a SharePoint list but the data is stored externally. That means, for example, that you can't set up SharePoint alerts and workflows on the records. If you truly need to push the data from Active Directory into a SharePoint list, you'll need to explore other options.
One such option is to have a piece of code run on a scheduled basis to continually update a SharePoint list with information from Active Directory. This could take any of the following forms:
A custom SharePoint timer job written in .NET
A custom Powershell script (or console application) located on one of your SharePoint web front end servers that can be run as a Windows Scheduled Task
A site workflow with an action to query Active Directory and use the resulting information to populate a list
The challenge in every case will be programmatically updating existing records in the SharePoint list, unless you take the easy way out and just delete and re-create each record every time the process runs.

developing web part for sharepoint online with visual studio without local sharepoint server

Iam trying to develop webpart for firm website on SharePoint with visual studio, the problem is that there is no solution for SharePoint online - Visual web part. When i try to create SharePoint 2013 - visual web part, I get an
error message.
The only thing there is for Sharepoint online is Apps for Sharepoint and that isn't a web part, or atleast I haven't found a way to use it as such.
When I talk to my supervisor about the error, he tells me that they can't create a virtual server for me to install the SharePoint server on and I have to code it through the Sharepoint online.
Is there any way for me to develop and deploy the webpart with an online Sharepoint server instead of local one or to atleast create it through the apps for Sharepoint?
You can use App Parts, those are Web Parts that display content from an installed App, you can add them at any page of your site as normal Web Parts, App Parts are deployed in the same package as your App, so you can have everything in the same solution.
There are plenty of resources that will help you to develop Apps and to include App Parts also, just look for the right concept in google and you will find it.
There are two kinds of SharePoint Apps (or Add-ins which is the new name), the first one is SharePoint Hosted App and the second one is SharePoint Provider Hosted App, the one you need will depend on the functionality you want to achieve, but as a general reference you can think on the data source that you want to consume in your solution, e.g. if the data to be used by the App is in the SP Site where you are going to install it, then all you need is a SharePoint Hosted App, however if the data is in an external location like databases stored in local servers, then you will need SharePoint Provider Hosted App. Of course this is just a very basic view of this topic, there are other reasons to use one or the other but its pointless to make a full list here. This is a wide topic and you can find tons of articles and guides about this.
If all you need is a simple webpart to display some content with a nice look or roll up some content and provide an output based on it, then you can use a SharePoint Hosted App, which is the easiest to develop and deploy, with this kind of app you can use JavaScript get the data from your site, and then you can display your output in an App Part.
I'm sorry to not provide specific pages to read, but that's just because it's better to look for the guides that be easier for you to understand and that may vary from person to person, all you need to know is the concepts and topics to search for.
If you want me to help you with this please send me a message (my profile).

Call external service from SharePoint Online web part

We are in the process of moving an on-premise SharePoint installation to SharePoint Online. We have a number of existing C# web parts that we need to convert. These web parts currently access some of our on-premise data... we need to get the web parts working on SharePoint Online; however, we're not certain of the best approach.
We've looked at BCS, but it seems that it is geared more towards synchronizing lists of data via basic CRUD methods. For many of our applications, we are not looking to synchronize lists, we are looking more towards action-oriented methods on a service that can be called on-demand as needed by the web part.
We don't believe the call can be client-side, as the users will often be accessing SharePoint Online from workstations that are not joined to our domain, and we don't want the user to have to separately authenticate to our service (i.e. we want our service to trust only the SharePoint Online backend).
Our ideal setup would be to have our C# code for the web part call into our web service (hosted on our domain, authenticating with a service account from the SPO secure store), passing the current username from the SharePoint context, and getting back a response that the web part can then use for its processing.
But as we understand, the web parts in SharePoint Online are sandboxed in such a way that they cannot make external HTTPS calls via HttpWebRequest.
We've searched for how-to examples or documentation related to our use case, and haven't found anything saying it's possible or that it's not possible. Does anybody know if it's possible for a web part to get data in this way? Is there some other direction we should be taking to achieve this?
In SharePoint online, if you are developing a SharePoint hosted app; You will be able to call external endpoints (EPs) after adding these endpoints in the manifest file.
If you haven't added these endpoint to the manifest file, This means you are not permitting the app to call an external EPs.
You don't need BCS in SharePoint online to call external EPs. Here is a sample on how to do this using JavaScript.
https://msdn.microsoft.com/en-us/library/office/fp179895.aspx
Let me know if you have any other questions.

Resources