Sample code for 30+ languages & platforms
PowerBuilder

Resolve the FTP Password from OS Secure Storage

See more FTP Examples

Demonstrates the EnableSecrets property, which lets password properties contain a secret specification beginning with !! that Chilkat resolves from the operating system's secure storage instead of using the literal text.

Background: This is a cleaner alternative to reading a secret yourself and assigning it: with EnableSecrets on, you set the password to a reference like !!my_secret_name and Chilkat fetches the real value from the platform's secure store. The literal password never appears in your source or configuration, which is exactly the practice recommended throughout these examples.

Chilkat PowerBuilder Downloads

PowerBuilder
integer li_rc
integer li_Success
oleobject loo_Ftp

li_Success = 0

loo_Ftp = create oleobject
li_rc = loo_Ftp.ConnectToNewObject("Chilkat.Ftp2")
if li_rc < 0 then
    destroy loo_Ftp
    MessageBox("Error","Connecting to COM object failed")
    return
end if

loo_Ftp.Hostname = "ftp.example.com"
loo_Ftp.Username = "myFtpLogin"

//  EnableSecrets (default 0) allows password properties to contain a "secret specification"
//  beginning with "!!" that Chilkat resolves from the operating system's secure storage instead
//  of using the literal text.
loo_Ftp.EnableSecrets = 1

//  Provide a secret specification rather than a literal password.  Chilkat looks up the named
//  secret in the OS secure store.
loo_Ftp.Password = "!!my_ftp_password_secret"

li_Success = loo_Ftp.Connect()
if li_Success = 0 then
    Write-Debug loo_Ftp.LastErrorText
    destroy loo_Ftp
    return
end if

Write-Debug "Connected using a password from OS secure storage."

li_Success = loo_Ftp.Disconnect()
if li_Success = 0 then
    Write-Debug loo_Ftp.LastErrorText
    destroy loo_Ftp
    return
end if



destroy loo_Ftp