<!--
{
  "availability" : [
    "iOS: 5.0.0 -",
    "iPadOS: 5.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.7.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "GSS",
  "identifier" : "/documentation/GSS/gss_aapl_initial_cred(_:_:_:_:_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "GSS"
    ],
    "preciseIdentifier" : "c:@F@gss_aapl_initial_cred"
  },
  "title" : "gss_aapl_initial_cred(_:_:_:_:_:)"
}
-->

# gss_aapl_initial_cred(_:_:_:_:_:)

Acquires a new credential using a password or certificate.

```
func gss_aapl_initial_cred(_ desired_name: gss_name_t, _ desired_mech: gss_const_OID, _ attributes: CFDictionary?, _ output_cred_handle: UnsafeMutablePointer<gss_cred_id_t?>, _ error: UnsafeMutablePointer<Unmanaged<CFError>?>?) -> OM_uint32
```

## Parameters

`desired_name`

The name to use to acquire the credential. Import the name using [`gss_import_name(_:_:_:_:)`](/documentation/GSS/gss_import_name(_:_:_:_:)). Ensure that the mechanism specified by the `desired_mech` parameter supports the name type.

`desired_mech`

The mechanism to use to acquire the credential, for example [`GSS_KRB5_MECHANISM`](/documentation/GSS/GSS_KRB5_MECHANISM) or [`GSS_NTLM_MECHANISM`](/documentation/GSS/GSS_NTLM_MECHANISM). Use [`gss_indicate_mechs(_:_:)`](/documentation/GSS/gss_indicate_mechs(_:_:)) to get a complete list of supported mechanisms.

`attributes`

A dictionary that includes either the key [`kGSSICPassword`](/documentation/GSS/kGSSICPassword) to specify a password or [`kGSSICCertificate`](/documentation/GSS/kGSSICCertificate) to name a certificate for use in acquiring the credential. It may also contain any of the other keys listed in Initial Credential Keys in [Credential Management](/documentation/GSS/credential-management) to optionally condition the operation.

`output_cred_handle`

A credential pointer that the function sets to point at the new credential on success, or sets to [`GSS_C_NO_CREDENTIAL`](/documentation/GSS/GSS_C_NO_CREDENTIAL) on failure. Use [`gss_release_cred(_:_:)`](/documentation/GSS/gss_release_cred(_:_:)) or [`gss_destroy_cred(_:_:)`](/documentation/GSS/gss_destroy_cred(_:_:)) to release the credential’s memory when you are done with it.

`error`

An error pointer that the function sets to point at a new error object if the function call fails. Pass `NULL` to ignore this error. When an error does exist, it describes the reason for the failure, and you are responsible for releasing it with `CFRelease`.

## Return Value

A status code set to [`GSS_S_COMPLETE`](/documentation/GSS/GSS_S_COMPLETE) if the call succeeds, or some other value indicating the reason for failure if not.

## Discussion

Don’t call this function on a UI update thread because it may block on network activity.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)