MarketingServiceAgent Constructor (String, String[], IPromptForCredentials)
Initializes a MarketingServiceAgent object to run against the specified Marketing Web service with the specified allowable authentication methods and authentication credential callback method.
Namespace: Microsoft.CommerceServer.Marketing
Assembly: Microsoft.CommerceServer.Marketing.CrossTierTypes (in Microsoft.CommerceServer.Marketing.CrossTierTypes.dll)
Syntax
'Declaration
Public Sub New ( _
serviceUrl As String, _
allowedAuthModes As String(), _
credentialPrompter As IPromptForCredentials _
)
'Usage
Dim serviceUrl As String
Dim allowedAuthModes As String()
Dim credentialPrompter As IPromptForCredentials
Dim instance As New MarketingServiceAgent(serviceUrl, _
allowedAuthModes, credentialPrompter)
public MarketingServiceAgent(
string serviceUrl,
string[] allowedAuthModes,
IPromptForCredentials credentialPrompter
)
public:
MarketingServiceAgent(
String^ serviceUrl,
array<String^>^ allowedAuthModes,
IPromptForCredentials^ credentialPrompter
)
public function MarketingServiceAgent(
serviceUrl : String,
allowedAuthModes : String[],
credentialPrompter : IPromptForCredentials
)
Parameters
- serviceUrl
Type: System..::.String
The URL of the Marketing Web service to access
- allowedAuthModes
Type: array<System..::.String>[]()[]
The list of allowable authentication methods. Use DefaultAuthMethods to indicate the default set of authentication methods.
- credentialPrompter
Type: Microsoft.CommerceServer..::.IPromptForCredentials
A callback interface that will be invoked when the current user's default credentials are not valid for the current Web service.
Remarks
The returned MarketingServiceAgent will not prompt on authentication failure.
Examples
This example shows how to initialize a ServiceAgent with a CredentialPrompter callback.
using System.Net;
using Microsoft.CommerceServer;
using Microsoft.CommerceServer.Marketing;
public ServiceAgent CreateMarketingAgent(string url)
{
MarketingServiceAgent mktgAgent = new MarketingServiceAgent(
url, ServiceAgent.DefaultAuthMethods, new MyCredentialPrompter());
return mktgAgent;
}
public class MyCredentialPrompter : IPromptForCredentials
{
public NetworkCredential PromptForCredentials(string url, string authType)
{
// Typically these values would be retrieved from a
// dialog box presented to a user prompting them to
// enter authentication credentials.
string username = "theUser";
string password = "pwd";
string domain = "domain";
NetworkCredential credentials = new NetworkCredential(
username, password, domain);
return credentials;
}
}
Permissions
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.