---
title: SecKeychainSearchCreateFromAttributes
framework: security
role: symbol
role_heading: Function
path: security/seckeychainsearchcreatefromattributes
---

# SecKeychainSearchCreateFromAttributes

Creates a search object matching a list of zero or more attributes.

## Declaration

```occ
OSStatus SecKeychainSearchCreateFromAttributes(CFTypeRef keychainOrArray, SecItemClass itemClass, const SecKeychainAttributeList *attrList, SecKeychainSearchRef*searchRef);
```

## Parameters

- `keychainOrArray`: A reference to an array of keychains to search, a single keychain, or NULL to search the user’s current keychain search list. Use the function doc://com.apple.security/documentation/Security/SecKeychainCopySearchList(_:) to retrieve the user’s default search list.
- `itemClass`: The keychain item class. See doc://com.apple.security/documentation/Security/SecItemClass for valid constants.
- `attrList`: A pointer to a list of zero or more keychain attribute records to match. Pass NULL to match any keychain attribute.
- `searchRef`: On return, a pointer to the current search object. In Objective-C, call the doc://com.apple.documentation/documentation/CoreFoundation/CFRelease function to release this object when you are finished using it.

## Return Value

Return Value A result code. See Security Framework Result Codes.

## Discussion

Discussion important: This function is deprecated. Use SecItemCopyMatching(_:_:) instead. Each item stored in the keychain contains data (such as a certificate), which is indexed by the item’s attributes. You look up an item in a keychain by its attributes. If you find a match, you can then retrieve the item’s data. Use the search object created by this function as input to the SecKeychainSearchCopyNext function to find a keychain item and the SecKeychainItemCopyAttributesAndData(_:_:_:_:_:_:) function to retrieve the item’s data. To find and obtain data from a password keychain item, use the SecKeychainFindInternetPassword(_:_:_:_:_:_:_:_:_:_:_:_:_:_:_:) or SecKeychainFindGenericPassword(_:_:_:_:_:_:_:_:) function.
