Creating SharePoint site collection using Admin.asmx web service - sharepoint

I am creating a site collection by calling a built-in SharePoint web service.
http://Server_Name/_vti_adm/admin.asmx
This web service has a method called CreateSite which allows users to create a site collection. Pretty straight forward (method documentation).
It creates a site with a URL such as:
http://Server_Name/sites/SiteCollection_Name
I would like to create a site collection where the Name of the Site comes first, such as:
http://SiteCollection_Name/Server_Name
I remember there is a property called UseHostHeaderAsSiteName
I can't see an option to use this property with CreateSite method. How do we use this property or any method to create a site that will give the URL such as:
http://SiteCollection_Name/Server_Name

What you describe - http://SiteCollection_Name/Server_Name - is not possible by the SP API. The URL format is protocol://server:port/path. The site collection can occur only in the path.
If you need different hostnames - the server part - you'd have to register them in the DNS mapped to your SP server IP address and then set up alternative access URLs in your SP web application so that they are accepted by SP. (SP is picky if you do not use the same hostname in the URL which it was installed with...)

Related

Registering an app permission in SharePoint

I am needing to connect from Azure (Azure data factory) to SharePoint sites
When I then create a linked service, I get the following error
Failed to get metadata of odata service, please check if service url and
credential is correct and your application has permission to the resource.
So, here is what I am doing - detailed:
I registered an app in Azure Active Directory and then went to Grant permission to that app ("add-in" in SharePoint language, if I get it right) with the SharePoint.
So, in the following, I am not understanding:
1.) What to put for domain ? and for redirect.
Is it something like "www.myCompanyDomain.com" and http://www.myCompanyDomain.com ?
or is it something to be taken from Azure Registered app configuration ?
) In the XML pasted, the "Scope" - Do I specify it literally as it is shown ? (Actually http://sharepoint/content/sitecollection) or is it to be replaced with my company's sharepoint Farm URL ?
Would appreciate any help ...
In domain you can use localhost and https://localhost in redirect url like following pic
In the XML, just specify it literally as it is shown and don't replace with your company's sharepoint Farm URL. You can refer to the document for the scope
https://learn.microsoft.com/en-us/sharepoint/dev/sp-add-ins/add-in-permissions-in-sharepoint

Access an internal URL on SharePoint Online?

In my company we have some internal applications what we would like to link to in the cloud.
Do I just need to add an Embed web part in SPO and then add an iframe to a https of the local application (that can only be acccessed on our network) ?
Thanks
P
I believe this is what you need:
https://learn.microsoft.com/en-us/sharepoint/administration/configure-alternate-access-mappings
Each web application can be associated with a collection of mappings between internal and public URLs. Both internal and public URLs consist of the protocol and domain portions of the full URL (for example, https://www.fabrikam.com). A public URL is what users type to access the SharePoint site, and that URL is what appears in the links on the pages. Internal URLs are in the URL requests that are sent to the SharePoint site. Many internal URLs can be associated with a single public URL in multi-server farms (for example, when a load balancer routes requests to specific IP addresses to various servers in the load-balancing cluster).
Each web application supports five collections of mappings per URL. The five collections correspond to five zones (default, intranet, extranet, Internet, and custom). When the web application receives a request for an internal URL in a particular zone, links on the pages returned to the user have the public URL for that zone. For more information, see Plan alternate access mappings for SharePoint 2013.
Add an internal URL
On the Alternate Access Mappings page, click Add Internal URLs.
If the mapping collection that you want to change is not specified, then choose one. In the Alternate Access Mapping Collection section, on the Alternate Access Mapping Collection menu, click Change alternate access mapping collection.
On the Select an Alternate Access Mapping Collection page, click a mapping collection.
In the Add internal URL section, in the URL protocol, host and port box, type the new internal URL (for example, https://www.fabrikam.com).
In the Zone list, click the zone for the internal URL.
Click Save.

How to configure SharePoint to work for 2 different domains on the internet?

We have a SharePoint site which serves as our company site on the internet. Our company has 2 domains ".com" and ".co.uk". SharePoint works fine when you access the site using the ".com" domain. The problem is, when you try to access the site using the ".co.uk" domain, some pages (ones including custom lists, settings pages) do not work properly.
After doing some research, I found out that I needed to add the ".co.uk" domain under Sharepoint access mappings to make it work properly, but when I do that, I am redirected to the ".com" domain. By the way, the".com" domain already exists in the accesss mappings page.
So, what's the best way to configure our Sharepoint site to work for 2 different domains?
In addition to the alternate address mapping create a IIS website for it. This link might not 100% apply to what your using, but you should be able to make ends meet with it.
http://www.isaserver.org/img/upl/spskit/3quickstart/3quickstart.htm#_Toc58577520
I solved the problem today. Here's how:
First I learned how to extend a Sharepoint site using the video: http://technet.microsoft.com/en-us/sharepoint/Video/ff679931.
In SharePoint Central Administration, I extended the default site (SharePoint - 80) for the ".com" domain.
Used "Create a new IIS web site Name" option, used domain name as the name,
Used port 80, domain name as the host header and the default sharepoint path,
Didn't change Authentication and SSL options, allowed anonymous access
Used the ".com" domain in URL and used Internet as the zone.
After extending a new IIS site was created. In Internet Manager, I clicked "Edit Bindings" option for the new site. The ".com" domain was already set in bindings. I added the ".co.uk" domain into bindings as well.
In Central Administration > Alternate Access Mappings, I set the ".com" domain URL as the Default zone and the ".co.uk" domain as the Internet zone. This automatically added internal URLs for both domains.

How to find the URL of a SharePoint web application given the url of a Site within that

I need to find the URL of the web application of a given Site (say I have an url http://code/sites/java. Given the url of this site collection i need the URL of the web app that hosts this site collection. In this case it will be http://code. ) Any input will be appreciated.
If you have an SPWeb object use its Site property. If you have an SPSite object use its WebApplication property. If you don't have either, create an SPSite object from that URL.
From the SPWebApplication object use the AlternateUrls property.
From the SPAlternateUrlCollection object retrieve the SPAlternateUrl for your desired zone.
From the SPAlternateUrl object get the actual URL.
The reason why you need to go through the alternate URL collection is because of the alternate access mappings you can associate with a web application. For example all web apps start with Default, which can be extended to Intranet, Extranet, etc.
Remember to use dispose with the above objects as necessary.
Try this:
string path= HttpContext.Current.Request.Url.Authority
You will get the url of the Web Application

Getting (Public) Internet URL for the Sharepoint Portal Site

I have a custom infopath workflow which allows users to submit expesne reports. Whenever someone submits an expense report in the Forms Library the workflow is initiated. The workflow checks the weburl and using a generic method creates a link to point to the workflow item and sends this link in a mail to the submitter and approvers.
Now what i want to achieve is that i need a way to point to the workflow item using a public url so even if the user is submitting a request from intranet or internet the link will be pointing to the internet url and hence the users can open items from their mailbox using internet url when the intranet is not available.
So i guess in short i need a way to get the public url for a site. Also keeping in mind that site may be extended for internet with some security settings in place. What would be the easiest and most efficient way to do this.
Relative path of you Page or the Link will be same irrespective of the Zone from which the user access the Site. All you need to change in the URL is the host name part.
You can get the URL for any Zone with the Following code
SPContext.Current.Site.WebApplication.GetResponseUri(Microsoft.SharePoint.Administration.SPUrlZone.Default).AbsoluteUri
You can make sure you always get URLs from a specific zone by creating a new SPSite object and specifying the zone for it in the constructor. In your case you could try with the Default zone (SharePoint uses URLs from this zone when sending emails for example) or the Internet zone. You have a small sample below:
using(SPSite site = new SPSite(currentSiteId, SPUrlZone.Default)
{
string publicUrl = site.MakeFullUrl(serverRelativeUrl);
// note that MakeFullUrl takes a server relative url not a site relative one
}
If I understand what you are attempting, you want an internet accessible method to access a SharePoint workflow object. Correct me if I am wrong.
Here is what I would do: I would set up a simple website w/ DNS that has a single page that exposes the workflow object. That way, you can just use this site as the base for the link in the notification.
Example: I have an HTML forms engine that I wrote a while back. A customer just requested that it be accessible on the internet as well. I created a new site in IIS, reverse proxied the IP address, and voila, my intranet application is exposed to the internet. Of course, there are security issues and small intranet caviats that had to be taken care of, but nothing too major.
Hope that helps.

Resources