Platforms to show: All Mac Windows Linux Cross-Platform

The module KeychainManagerMBS

module KeychainManagerMBS
Type Topic Plugin Version macOS Windows Linux iOS Targets
module Keychain MBS MacClassic Plugin 13.1 ✅ Yes ❌ No ❌ No ✅ Yes All
The module for global keychain functions.
Example
// build query
dim query as new Dictionary

dim domain as string = "test.test"
dim username as string = "testuser"

query.value( KeychainManagerMBS.kSecAttrServer ) = Domain
query.value( KeychainManagerMBS.kSecAttrAccount ) = Username
query.value( KeychainManagerMBS.kSecClass ) = KeychainManagerMBS.kSecClassInternetPassword
query.Value( KeychainManagerMBS.kSecMatchLimit ) = KeychainManagerMBS.kSecMatchLimitOne

// Build Dictionary with new values
dim newValues as new Dictionary
newValues.value( KeychainManagerMBS.kSecAttrComment ) = "Just a test"

// and update
if KeychainManagerMBS.UpdateItem(query, newValues) then
MsgBox "OK"
else
MsgBox "Failed."
end if

For iOS please define a keychain access group in Xojo build settings. Then prefix it with your developer ID as you can see it in the generated entitlement file inside your app. Pass the prefixed string to our functions with kSecAttrAccessGroup key.

Constants

Constant Value Description
kSecAppleSharePasswordItemClass "ashp" Specifies a keychain item's class code. Indicates that the item is an AppleShare password.
kSecGenericPasswordItemClass "genp" Specifies a keychain item's class code. Indicates that the item is a generic password.
kSecInternetPasswordItemClass "inet" Specifies a keychain item's class code. Indicates that the item is an Internet password.

Error Codes

Constant Value Description
ErrorAuthorizationFailed -25293 The user name or passphrase you entered is not correct.
ErrorDuplicatedItem -25299 The specified item already exists in the keychain.
ErrorFailedToAllocated -108 Failed to allocate memory.
ErrorFailedToDecode -26275 Unable to decode the provided data.
ErrorInteractionNotAllowed -25308 User interaction is not allowed.
ErrorInvalidParameter -50 Invalid Parameters.
ErrorNone 0 No error.
ErrorNotAvailable -25291 No keychain is available. You may need to restart your computer.
ErrorNotFound -25300 The specified item could not be found in the keychain.

Keychain Preference Domain Constants

Constant Value Description
kSecPreferencesDomainCommon 2 Indicates the preferences are common to everyone.
Available in OS X v10.3 and later.
kSecPreferencesDomainDynamic 3 Indicates a dynamic search list (typically provided by removable keychains such as smart cards).
Available in OS X v10.4 and later.
kSecPreferencesDomainSystem 1 Indicates the system or daemon preference domain preferences.
Available in OS X v10.3 and later.
kSecPreferencesDomainUser 0 Indicates the user preference domain preferences.
Available in OS X v10.3 and later.

Some examples which use this module:

Blog Entries

Release notes


The items on this page are in the following plugins: MBS MacClassic Plugin.


The biggest plugin in space...