<!--
{
  "availability" : [
    "macOS: 10.0.0 - 10.7.0"
  ],
  "documentType" : "symbol",
  "framework" : "Security",
  "identifier" : "/documentation/Security/SecIdentitySetPreference",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "Security"
    ],
    "preciseIdentifier" : "c:@F@SecIdentitySetPreference"
  },
  "title" : "SecIdentitySetPreference"
}
-->

# SecIdentitySetPreference

Sets the preferred identity for the specified name and key use.

```
OSStatus SecIdentitySetPreference(SecIdentityRef identity, CFStringRef name, CSSM_KEYUSE keyUsage);
```

## Parameters

`identity`

A reference to the preferred identity.

`name`

A string containing a URI, RFC822 email address, DNS host name, or other name that uniquely identifies a service requiring this identity.

`keyUsage`

A key use value, as defined in `Security.framework/cssmtype.h`. Pass `0` if you don’t want to specify a particular key use.

## Return Value

A result code. See [Security Framework Result Codes](/documentation/Security/security-framework-result-codes).

## Discussion

Use [`SecIdentitySetPreferred(_:_:_:)`](/documentation/Security/SecIdentitySetPreferred(_:_:_:)) for new development instead.

---

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)