资讯

精准传达 • 有效沟通

从品牌网站建设到网络营销策划,从策略到执行的一站式服务

sharepoint函数 sharepoint csom

如何试用office 365 及 sharepoint online

在本地环境中对提供程序承载的应用程序使用 ACS 的必备组件

创新互联建站提供高防服务器、云服务器、香港服务器、绵阳机房托管

确保拥有以下组件。

本地 SharePoint 2013 开发环境。请参阅如何:设置 SharePoint 应用程序的本地开发环境。

Office 365 SharePoint 网站。如果还没有此类网站,并且希望快速设置开发环境,您可以注册 Office 365 开发人员订阅、设置您的工具和环境并开始部署应用程序。

远程安装的或已在安装 SharePoint 2013 的计算机上安装的 Visual Studio 2012。

Visual Studio 2012 Office 开发人员工具。

在已安装 SharePoint 2013 的计算机上安装的 64 位版本 Microsoft Online Services 登录助手。

在已安装 SharePoint 2013 的计算机上安装的用于 Windows PowerShell 的 Microsoft Online Services 模块(64 位)。

创建一个证书并使其成为 SharePoint 2013 本地安装的安全令牌服务 (STS) 证书

您需要使用您自己的证书替换 SharePoint 2013 本地安装的默认安全令牌服务 (STS) 证书。本文为您提供了使用 IIS 中的"创建自签名证书"选项创建并导出测试证书的示例。您还可以使用证书颁发机构颁发的商业证书。

首先创建测试 .pfx 证书文件,然后创建相应的测试 .cer 文件。

还可以使用 MakeCert 测试程序生成测试 X.509 证书。

创建测试 .pfx 证书文件

在 IIS 管理器中,选择左侧树视图中的 ServerName 节点。

选择"服务器证书",如图 1 所示。

图 1. IIS 中的"服务器证书"选项

在右侧链接集中单击"创建自签名证书"链接,如图 2 所示。

图 2."创建自签名证书"链接

将证书命名为 SampleCert,然后选择"确定"。

右键单击该证书,然后选择"导出",如图 3 所示。

图 3. 导出测试证书

注释

使用 SharePoint Server 2013 和 Office 365 配置单向混合环境文档(可在 SharePoint 2013 混合资源页下载)详细解释了如何使用来自知名证书颁发机构的证书或自签名证书替换本地场的默认 STS 证书。

配置 SharePoint 2013 的本地安装以使用 ACS

图 4 显示了在本地网站上运行的提供程序承载应用程序整体架构内启用所需连接的四个步骤。还显示了应用程序运行时的 OAuth 令牌流。

图 4. 使用 Office 365 SharePoint 网站对 SharePoint 的本地安装使用 ACS

在本地 SharePoint 2013 场中创建 ACS 代理。

将本地服务器的签名证书安装到 Office 365 租户。

将要运行应用程序的 SharePoint 2013 场上的站点的完全限定域名添加到 Office 365 租赁的服务主体名称集合中。

在 SharePoint 2013 场中创建应用程序管理代理。

以下函数可执行配置本地 SharePoint 2013 网站以使用 ACS 的所有任务。如果需要删除之前的配置,还可以使用此函数执行一些清理任务。可以使用多种方式在 PowerShell 中运行该函数。下面列出了一种方法:

在本地 SharePoint 服务器中,将函数中的代码复制到文本文件中,并以名称 MySharePointFunctions.psm1 将其保存到以下任一文件夹中(不要同时保存到两个文件夹)。如果其中包含尚不存在的文件夹,则可能必须创建部分路径。请注意,在两种情况下,路径中最底层的文件夹必须与文件同名。

提示

文件必须另存为 ANSI 格式,而非 UTF-8。PowerShell 在加载非 ANSI 格式的文件时,可能会报告语法错误。Windows 记事本会默认将其保存为 ANSI。如果使用其他任何编辑器保存文件,请确保将其保存为 ANSI。

C:\users\username\documents\windowspowershell\modules\MySharePointFunctions,其中 username 是即将执行文件的场管理员。

C:\windows\system32\windowspowershell\V1.0\modules\MySharePointFunctions

以管理员身份打开 SharePoint Management Shell并运行以下 cmdlet,以验证 MySharePointFunctions 模块是否已列出。

Windows PowerShell

Get-Module –listavailable

运行以下 cmdlet 以导入模块。

Windows PowerShell

Import-Module MySharePointFunctions

运行以下 cmdlet,验证 Connect-SPFarmToAAD 函数是否已作为模块的一部分列出:

Windows PowerShell

Get-Command -module MySharePointFunctions

运行以下 cmdlet,验证 Connect-SPFarmToAAD 函数是否已加载。

Windows PowerShell

ls function:\ | where {$_.Name -eq "Connect-SPFarmToAAD"}

如果要替换与 Microsoft Azure Active Directory 的现有连接,请使用此开关。如果您已经在场中创建了一个 ACS 代理,则它会删除现有代理。

-RemoveExistingSTS(可选)

如果要替换与 Microsoft Azure Active Directory 的现有连接,请使用此开关。它会删除从较早的 ACS 连接遗留下来的现有可信安全令牌颁发者。

-RemoveExistingSPOProxy(可选)

如果要替换与 Microsoft Azure Active Directory 的现有连接,请使用此开关。如果您已经在场中创建了一个应用程序管理代理,则它会删除现有代理。

-RemoveExistingAADCredentials(可选)

如果要替换 Office 365 SharePoint 网站,请使用此开关。

Set-SPAuthenticationRealm -ServiceContext $SharePointWeb -Realm $AADRealmId

$LocalSTS = Get-SPSecurityTokenServiceConfig

$LocalSTS.NameIdentifier = '{0}@{1}' -f $SP_APPPRINCIPALID,$AADRealmId

$LocalSTS.Update()

#Allow connections over HTTP if the switch is specified.

if ($AllowOverHttp.IsPresent -and $AllowOverHttp -eq $True) {

$serviceConfig = Get-SPSecurityTokenServiceConfig

$serviceConfig.AllowOAuthOverHttp = $true

$serviceConfig.AllowMetadataOverHttp = $true

$serviceConfig.Update()

}

#Step 1: Set up the ACS proxy in the on-premises SharePoint farm. Remove the existing ACS proxy

#if the switch is specified.

if ($RemoveExistingACS.IsPresent -and $RemoveExistingACS -eq $True) {

Get-SPServiceApplicationProxy | ? DisplayName -EQ $ACS_APPPROXY_NAME | Remove-SPServiceApplicationProxy -RemoveData -Confirm:$false

}

if (-not (Get-SPServiceApplicationProxy | ? DisplayName -EQ $ACS_APPPROXY_NAME)) {

$AzureACSProxy = New-SPAzureAccessControlServiceApplicationProxy -Name $ACS_APPPROXY_NAME -MetadataServiceEndpointUri $ACSMetadataEndpoint -DefaultProxyGroup

}

#Remove the existing security token service if the switch is specified.

if ($RemoveExistingSTS.IsPresent) {

Get-SPTrustedSecurityTokenIssuer | ? Name -EQ $ACS_STS_NAME | Remove-SPTrustedSecurityTokenIssuer -Confirm:$false

}

if (-not (Get-SPTrustedSecurityTokenIssuer | ? DisplayName -EQ $ACS_STS_NAME)) {

$AzureACSSTS = New-SPTrustedSecurityTokenIssuer -Name $ACS_STS_NAME -IsTrustBroker -MetadataEndPoint $ACSMetadataEndpoint

}

#Update the ACS Proxy for OAuth authentication.

$ACSProxy = Get-SPServiceApplicationProxy | ? Name -EQ $ACS_APPPROXY_NAME

$ACSProxy.DiscoveryConfiguration.SecurityTokenServiceName = $ACS_APPPRINCIPALID

$ACSProxy.Update()

#Retrieve the local STS signing key from JSON metadata.

$SPMetadata = Invoke-RestMethod -Uri ($SP_METADATAEP_FSTRING -f $SharePointWeb)

$SPSigningKey = $SPMetadata.keys | ? usage -EQ "Signing" | % keyValue

$CertValue = $SPSigningKey.value

#Connect to Office 365.

Connect-MsolService -Credential $O365Credentials

#Remove existing connection to an Office 365 SharePoint site if the switch is specified.

if ($RemoveExistingAADCredentials.IsPresent -and $RemoveExistingAADCredentials -eq $true) {

$msolserviceprincipal = Get-MsolServicePrincipal -AppPrincipalId $SP_APPPRINCIPALID

[Guid[]] $ExistingKeyIds = Get-MsolServicePrincipalCredential -ObjectId $msolserviceprincipal.ObjectId -ReturnKeyValues $false | % {if ($_.Type -ne "Other") {$_.KeyId}}

Remove-MsolServicePrincipalCredential -AppPrincipalId $SP_APPPRINCIPALID -KeyIds $ExistingKeyIds

}

#Step 2: Upload the local STS signing certificate

New-MsolServicePrincipalCredential -AppPrincipalId $SP_APPPRINCIPALID -Type Asymmetric -Value $CertValue -Usage Verify

#Step 3: Add the service principal name of the local web application, if necessary.

$indexHostName = $SharePointWeb.IndexOf('://') + 3

$HostName = $SharePointWeb.Substring($indexHostName)

$NewSPN = '{0}/{1}' -f $SP_APPPRINCIPALID, $HostName

$SPAppPrincipal = Get-MsolServicePrincipal -AppPrincipalId $SP_APPPRINCIPALID

if ($SPAppPrincipal.ServicePrincipalNames -notcontains $NewSPN) {

$SPAppPrincipal.ServicePrincipalNames.Add($NewSPN)

Set-MsolServicePrincipal -AppPrincipalId $SPAppPrincipal.AppPrincipalId -ServicePrincipalNames $SPAppPrincipal.ServicePrincipalNames

}

#Remove the existing SharePoint Online proxy if the switch is specified.

if ($RemoveExistingSPOProxy.IsPresent -and $RemoveExistingSPOProxy -eq $True) {

Get-SPServiceApplicationProxy | ? DisplayName -EQ $SPO_MANAGEMENT_APPPROXY_NAME | Remove-SPServiceApplicationProxy -RemoveData -Confirm:$false

}

#Step 4: Add the SharePoint Online proxy

if (-not (Get-SPServiceApplicationProxy | ? DisplayName -EQ $SPO_MANAGEMENT_APPPROXY_NAME)) {

$spoproxy = New-SPOnlineApplicationPrincipalManagementServiceApplicationProxy -Name $SPO_MANAGEMENT_APPPROXY_NAME -OnlineTenantUri $SharePointOnlineUrl -DefaultProxyGroup

}

}

针对 Office 商店配置应用程序和 SharePoint Web 应用程序

如果想让用户能够从 Office 商店安装使用 ACS 的提供程序承载的应用程序,则有一个可供场管理员在生产环境中采用的可选配置步骤。(除非您打算从该环境下的存储安装使用 ACS 的应用程序,否则在 SharePoint 开发环境中毫无用处。)以下 cmdlet 能够实现此目标。可以对上述函数添加此代码。

Windows PowerShell

New-SPMarketplaceWebServiceApplicationProxy -Name "ApplicationIdentityDataWebServiceProxy" -ServiceEndpointUri "oauth.sellerdashboard.microsoft.com/ApplicationIdentityDataWebService.svc" –DefaultProxyGroup

如何:将 Outlook 与 SharePoint 文件夹同步

购买该书籍(该链接可能指向英文页面)章节示例 (该链接可能指向英文页面)在Outlook 中,可以将日历、联系人列表、任务列表、讨论板和文档库同步到 SharePoint 文件夹。基于同步时提供的 URL,Outlook 将创建基类型与 SharePoint 文件夹相同的新文件夹。例如,同步到 SharePoint 日历文件夹时将在 Outlook 中创建新的日历文件夹。SharePoint 同步文件夹存储在用户邮箱外部的其各自的 Outlook 个人文件夹 (.pst) 文件中。您可以通过使用 NameSpace 对象的 OpenSharedFolder 方法连接到 SharePoint 文件夹。请注意,您必须使用 stssync:// URL,该 URL 提供有关 SharePoint Server 和文件夹路径的详细信息,以及 Outlook 打开 SharePoint 文件夹所需的其他信息。 当以编程方式连接到 SharePoint 文件夹时,必须确定要用于创建共享关系的正确的 URL。由于 SharePoint 用户界面中并不提供文件夹的 stssync:// URL,因此需要手动将目标文件夹链接到 Outlook。然后,使用以下代码示例中的第一个过程 DisplaySharePointUrl 来获取正确的 URL。DisplaySharePointUrl 使用Table 对象在活动资源管理器窗口的当前文件夹中查找共享绑定信息。如果找到了一个或多个绑定上下文,则将显示所有可用共享上下文的 URL。 现在您有了正确的 URL 可用来创建共享关系。若要在 Outlook 中同步新的 SharePoint 文件夹,请在第二个过程 AddSpsFolder 中复制该 URL 并将其粘贴到字符串变量 calendarUrl 的分配中。AddSpsFolder 通过将 NameSpace.OpenSharedFolder 方法与 stssync:// URL(在此情况下,为 DisplaySharePointUrl 过程生成的 URL)一起使用,自动在 Outlook 中同步新的 SharePoint 文件夹。AddSpsFolder 还提供自定义文件夹名称“SPS 日历示例”,并指定 Outlook 来使用文件夹的默认生存时间 (TTL)。SharePoint 文件夹始终下载项目附件,这样您就必须在此处进行指定。 如果您使用 Microsoft Visual Studio 来测试该代码示例,在导入 Microsoft.Office.Interop.Outlook 命名空间时,必须先添加对 Microsoft Outlook 14.0 对象库组件的引用,并指定 Outlook 变量。using 语句不能直接出现在代码示例中的函数前面,但必须添加在公共 Class 声明前面。以下代码行显示了在 C# 中如何执行导入和赋值。

怎么在SharePoint 页面里添加JS函数

$("#id").append($("a").click(function(){ //点击事件 }) ); 只用javascript: 把事件与标签一起innerHTML在元素里搞定,比如: document.getElementById('sasd').innerHTML="";


标题名称:sharepoint函数 sharepoint csom
网站路径:http://cdkjz.cn/article/doeceii.html
多年建站经验

多一份参考,总有益处

联系快上网,免费获得专属《策划方案》及报价

咨询相关问题或预约面谈,可以通过以下方式与我们联系

大客户专线   成都:13518219792   座机:028-86922220