Share via


IUccCredentialCache.SetCredential Method

This content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release.

Adds a user credential for a specified security realm to the credential cache.

Namespace: Microsoft.Office.Interop.UccApi
Assembly: Microsoft.Office.Interop.UccApi (in microsoft.office.interop.uccapi.dll)

Syntax

'Declaration
Sub SetCredential ( _
    bstrRealm As String, _
    pCredential As UccCredential _
)
void SetCredential (
    string bstrRealm,
    UccCredential pCredential
)
void SetCredential (
    String^ bstrRealm, 
    UccCredential^ pCredential
)
void SetCredential (
    String bstrRealm, 
    UccCredential pCredential
)
function SetCredential (
    bstrRealm : String, 
    pCredential : UccCredential
)

Parameters

  • bstrRealm
    A value of the BSTR (string, for a .NET application) type. This specifies a security realm by which the specified credential is to be applied to authenticate a user.
  • pCredential
    A value of the IUccCredential* (UccCredential, for a .NET application) type. This specifies a credential used to authenticate a user.

Remarks

Credentials are organized by realms. For each realm there can be only one credential instance. If a credential cache does not hold a credential for a given realm, calling this method adds a credential. Calling SetCredential a second time with the same realm will replace the first instance of the credential in the cache with the second instance.

Win32 COM/C++ Syntax

HRESULT SetCredential
(
   BSTR bstrRealm,
   IUccCredential* pCredential
);

Note

In a Win32 application, the return value of a method or property is always an HRESULT value indicating the status of the call to the interface member. Any result of the operation is returned as a parameter marked with the [out, retval] attribute. In contrast, in a .NET application the HRESULT value indicating an error condition is returned as a COM exception and the [out, retval] parameter becomes the return value. For the UCC API-defined HRESULT values, see Trace and Handle Errors in Unified Communications Client API.

Example

The following method adds a credential to a credential cache. If the example method is called with a null credential parameter, the default cache credential is set. If a realm is not specified, the "global" realm is used.

private Boolean AddCredentialToCache(
   IUccCredentialCache pCache, 
   UccCredential pCredential, 
   string pRealm)
{
   Boolean returnValue = false;
   if (pCache == null)
   {
      return returnValue;
   }
   if (pRealm == null)
   {
      pRealm = "*";
   }
   UccCredential setCredential;
   setCredential = pCredential;
   if (setCredential == null)
   {
      setCredential = pCache.DefaultCredential;
   }
   try
   {
      pCache.SetCredential(pRealm, setCredential);
      returnValue = true;
   }
   catch { }
   return returnValue;
}

Thread Safety

All public static (Shared in Visual Basic) members of this type are thread-safe. Instance members are not guaranteed to be thread-safe.

Platforms

Development Platforms

Windows XP Professional with Service Pack 2 (SP2), Windows Server 2000 with Service Pack 4, Windows Server 2003, Windows Vista Ultimate Edition, Windows Vista Business Edition, Windows Vista Enterprise Edition

Target Platforms

See Also

Reference

IUccCredentialCache Interface
IUccCredentialCache Members
Microsoft.Office.Interop.UccApi Namespace