Platforms to show: All Mac Windows Linux Cross-Platform

Back to WindowsCredentialsMBS module.

WindowsCredentialsMBS.Delete(TargetName as String, Type as Integer = 1, Flags as Integer = 0) as Boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Windows MBS Win Plugin 26.5 ❌ No ✅ Yes ❌ No ❌ No Desktop, Console & Web
Deletes a credential from the user's credential set.
Example
// delete a password for a FileMaker database:

Var type As Integer = WindowsCredentialMBS.TypeGeneric
Var r As Boolean = WindowsCredentialsMBS.Delete("FMP: Assets", type)

If r Then
MessageBox "deleted"
Else
MessageBox WindowsCredentialsMBS.LastErrorMessage
End If

The credential set used is the one associated with the logon session of the current token. The token must not have the user's SID disabled.

TargetName: the name of the credential to delete.
Type: Type of the credential to delete.

If the value of the type parameter is DomainExtended, this function can delete a credential that specifies a user name when there are multiple credentials for the same target. The value of the TargetName parameter must specify the user name as Target|UserName.

Returns true on success or false on failure. LastError property is set.

WindowsCredentialsMBS.FindBestCredential(TargetName as String) as WindowsCredentialMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Windows MBS Win Plugin 26.5 ❌ No ✅ Yes ❌ No ❌ No Desktop, Console & Web
Searches the Credentials Management (CredMan) database for the set of generic credentials that are associated with the current logon session and that best match the specified target resource.

TargetName: the name of the target resource for which to find credentials.
Type: The type of credentials to search for. Currently, this function supports only TypeGeneric.

Returns credential if found or nil in case of an error.

WindowsCredentialsMBS.GetSessionTypes as Integer()

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Windows MBS Win Plugin 26.5 ❌ No ✅ Yes ❌ No ❌ No Desktop, Console & Web
Returns the maximum persistence supported by the current logon session.
Example
Var values() As Integer = WindowsCredentialsMBS.GetSessionTypes

if values = nil then
MessageBox WindowsCredentialsMBS.LastErrorMessage

Else

Var value As Integer = values(WindowsCredentialMBS.TypeGeneric)

Select Case value
Case WindowsCredentialMBS.PersistEnterprise
MessageBox "We can store generic credentials with enterprise persistence." // highest level
Case WindowsCredentialMBS.PersistLocalMachine
MessageBox "We can store generic credentials on local machine."
Case WindowsCredentialMBS.PersistSession
MessageBox "We can store generic credentials in session."
End Select

End If

A separate maximum persistence is returned for each credential type.

WindowsCredentialsMBS.List(Filter as String = "", Flags as Integer = 0) as WindowsCredentialMBS()

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Windows MBS Win Plugin 26.5 ❌ No ✅ Yes ❌ No ❌ No Desktop, Console & Web
Enumerates the credentials from the user's credential set.
Example
Var credentials() As WindowsCredentialMBS = WindowsCredentialsMBS.List

If credentials = Nil Then
MessageBox WindowsCredentialsMBS.LastErrorMessage
Else
For Each credential As WindowsCredentialMBS In credentials
MessageBox credential.TargetName+EndOfLine+credential.Comment+EndOfLine+credential.UserName
Next
End If

The credential set used is the one associated with the logon session of the current token. The token must not have the user's SID disabled.

Filter: The filter for the returned credentials. Only credentials with a TargetName matching the filter will be returned. The filter specifies a name prefix followed by an asterisk. For instance, the filter "FRED*" will return all credentials with a TargetName beginning with the string "FRED". If "" is specified, all credentials will be returned.

Flags: The value of this parameter can be zero or FlagsPreserveCredentialBlob.

Returns the credentials or nil in case of an error.

WindowsCredentialsMBS.Read(TargetName as String, Type as Integer = 1, Flags as Integer = 0) as WindowsCredentialMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Windows MBS Win Plugin 26.5 ❌ No ✅ Yes ❌ No ❌ No Desktop, Console & Web
Reads a credential from the user's credential set.
Example
// Read our value after using code in Write function.

Var credential As WindowsCredentialMBS = WindowsCredentialsMBS.Read("MyApp_Login")
MessageBox credential.TargetName+EndOfLine+credential.Comment+EndOfLine+credential.UserName

Var attrs() As WindowsCredentialAttributeMBS = credential.CredentialAttributes
Break // inspect in debugger

The credential set used is the one associated with the logon session of the current token. The token must not have the user's SID disabled.

TargetName: the name of the credential to read.
Type: The type of item to read. Default is WindowsCredentialMBS.TypeGeneric value.
Flags: Currently reserved and must be zero.

Returns a credential object or nil in case of an error. See LastError property and error constants.

If the value of the Type member of the WindowsCredentialMBS is TypeDomainExtended, a namespace must be specified in the target name. This function can return only one credential of the specified type.

WindowsCredentialsMBS.Write(Credential as WindowsCredentialMBS, Flags as Integer = 0) as Boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Windows MBS Win Plugin 26.5 ❌ No ✅ Yes ❌ No ❌ No Desktop, Console & Web
Creates a new credential or modifies an existing credential in the user's credential set.
Example
Var c As New WindowsCredentialMBS
c.Comment = "Xojo test"
c.TargetName = "MyApp_Login"
c.UserName = "John"
c.CredentialBlob = "Secret"
c.Type = c.TypeGeneric
c.Persist = c.PersistLocalMachine

Var attr As New WindowsCredentialAttributeMBS
attr.Keyword = "id"
attr.Text = "1234"

Var attrs() As WindowsCredentialAttributeMBS = c.CredentialAttributes
attrs.Add attr

If WindowsCredentialsMBS.Write(c) Then
MessageBox "saved"
Else
MessageBox WindowsCredentialsMBS.LastErrorMessage
End If

The new credential is associated with the logon session of the current token. The token must not have the user's security identifier (SID) disabled.

Credential: The Credential to be written.
Flags: Flags that control the function's operation. e.g. FlagsPreserveCredentialBlob to preserved existing credential.

Returns true on success or false on failure.

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


The biggest plugin in space...