GetNamedCredentials()
- Last UpdatedDec 15, 2025
- 1 minute read
Returns the username and password for the given named credential.
Category
Security
Syntax
Security.GetNamedCredentials("CredentialName");
where CredentialName is the name of the credential whose value you are retreiving.
Return value
The GetNamedCredentials() script function returns the the username and password for a named credential. You can specify if the username and password are returned as a string or as a SecureString.
Note: GetNamedCredentials() does not let you retrieve the domain name, if the credential you are retrieving includes domain.
Example
dim stCredentialName as string;
dim stUsername as string;
dim stPassword as System.Security.SecureString;
dim credentials as aaSecurity.Credentials;
stCredentialName = "cred1";
credentials = GetNamedCredentials(stCredentialName);
if(credentials.Values.Count > 0) then
if(credentials.ContainsKey("Username")) then
stUsername = credentials.Get("Username");
endif;
if(credentials.ContainsKey("Password")) then
dim networkcred as System.Net.NetworkCredential;
networkcred = new System.Net.NetworkCredential(stUsername,
credentials.Get("Password"));
stPassword = networkcred.SecurePassword;
endif;
endif;
Note: Use “stpassword” SecureString as required.