: Application.AddApplication (Método) (Microsoft.SharePoint.Portal.SingleSignon)
Adds or modifies an enterprise application definition.
Espacio de nombres:
Ensamblado: Microsoft.SharePoint.Portal.SingleSignon (in microsoft.sharepoint.portal.singlesignon.dll)
Sintaxis
'Declaración
<SingleSignonPermissionAttribute(SecurityAction.Demand, Access:=SingleSignonAccess.Minimal)> _
Public Shared Sub AddApplication ( _
App As ApplicationInfo, _
rgAppFields As ApplicationField(), _
appcd As ApplicationCreationDisposition _
)
'Uso
Dim App As ApplicationInfo
Dim rgAppFields As ApplicationField()
Dim appcd As ApplicationCreationDisposition
Application.AddApplication(App, rgAppFields, appcd)
[SingleSignonPermissionAttribute(SecurityAction.Demand, Access=SingleSignonAccess.Minimal)]
public static void AddApplication (
ApplicationInfo App,
ApplicationField[] rgAppFields,
ApplicationCreationDisposition appcd
)
Parámetros
- App
An ApplicationInfo object that specifies the enterprise application definition that is added.
- rgAppFields
An ApplicationField data type that contains the fields of an enterprise application definition. The maximum number of allowed ApplicationField data types is five. You must specify at least one ApplicationField data type.
appcd
One of the ApplicationCreationDisposition values that specifies how the enterprise application definition is created:If the enterprise application definition does not exist, it is created regardless of ApplicationCreationDisposition.
If the enterprise application definition exists and you specify ApplicationCreationDisposition. Overwrite and the ApplicationType data type is the same, the enterprise application definition is overwritten.
Comentarios
You can get or specify credentials only after you add the enterprise application definition to the single sign-on database. Users who are members of the single sign-on administrator account or the application definition manager account can add application definitions.
The result of each call to the AddApplication method is audited and stored in the single sign-on database. The ServiceAction enumeration recorded is AddApplication.
Ejemplo
The following code example shows how to use the AddApplication method.
using System;
using Microsoft.SharePoint.Portal.SingleSignon;
namespace SSOSampleCode
{
/// <summary>
/// Sample code for SharePoint Portal Single SignOn.
/// </summary>
class CMainEntry
{
[STAThread]
static void Main(string[] args)
{
try
{
//Create the application fields (max 5 fields).
Application.ApplicationField[] rgFields = new Application.ApplicationField[5];
rgFields[0] = new Application.ApplicationField(
"Field1 Label", //Application field name
true); //true == mask in the UI, false == don't mask in the UI
rgFields[1] = new Application.ApplicationField(
"Field2 Label",
false);
rgFields[2] = new Application.ApplicationField(
"Field3 Label",
true);
rgFields[3] = new Application.ApplicationField(
"Field4 Label",
false);
rgFields[4] = new Application.ApplicationField(
"Field5 Label",
true);
//Create group application information data.
Application.ApplicationInfo App = new Application.ApplicationInfo(
"MyIndividualApplicationID",
"My Individual Applicaiton Display Name",
Application.ApplicationType.Individual,
"someone@someplace.someext");
//Now, add the application.
Application.AddApplication(
App,
rgFields,
Application.ApplicationCreationDisposition.CreateNew);
Console.WriteLine("Successfully added the individual application!");
//Get the application.
Application.ApplicationInfo MyApp = null;
Application.GetApplication(
"MyIndividualApplicationID",
ref MyApp);
Console.WriteLine("Application Information:");
Console.WriteLine("Application ID: " + MyApp.ApplicationName);
Console.WriteLine("Application friendly name: " + MyApp.ApplicationFriendlyName);
Console.WriteLine("Application contact: " + MyApp.ContactName);
Console.WriteLine("Application type: " + MyApp.Type);
//Now, delete the application.
Application.DeleteApplication("MyIndividualApplicationID");
Console.WriteLine("Successfully deleted the individual application!");
}
catch (SingleSignonException esso)
{
Console.WriteLine("SingleSignonException caught.");
Console.WriteLine("Exception Code: " + "0x" + esso.LastErrorCode.ToString("x"));
Console.WriteLine("Source: " + esso.Source);
Console.WriteLine("StackTrace: " + esso.StackTrace);
Console.WriteLine("MethodName: " + esso.TargetSite.Name);
Console.WriteLine("Message: " + esso.Message);
}
catch (Exception e)
{
Console.WriteLine("Exception caught.");
Console.WriteLine("Source: " + e.Source);
Console.WriteLine("StackTrace: " + e.StackTrace);
Console.WriteLine("MethodName: " + e.TargetSite.Name);
Console.WriteLine("Message: " + e.Message);
}
}
}
}
Vea también
Referencia
Application (Clase)
Application (Miembros)
Microsoft.SharePoint.Portal.SingleSignon (Espacio de nombres)