[prev in list] [next in list] [prev in thread] [next in thread] 

List:       sas-l
Subject:    Passing username/password via VBA code to SAS (EG Scripting)
From:       Jos=?UTF-8?Q?=C3=A9_Alberto?= <biyectivo () PRODIGY ! NET ! MX>
Date:       2015-09-30 18:03:43
Message-ID: 0065972538886367.WA.biyectivoprodigy.net.mx () listserv ! uga ! edu
[Download RAW message or body]

Hi,
Simple question for you EG scripting gurus. How can I pass the username/password of \
the server (or at least have the server request them via a popup or whatever) when \
establishing a connection to a SAS Server via EG scripting?

My Hello World code is as follows. This was tested on a remote SAS Server that does \
not use LDAP to authenticate and apparently does not allow credentials to persist \
(and hence everytime someone tries to connect to it via EG, the username/password \
dialog pops up) and submitting via VBA throws the error pasted below.

Running the exact same code pointing to another remote SAS server (whose profile name \
is not "Grid" but "SAS Risk" works perfectly. This server is configured to \
authenticate via LDAP and also allows credential persistence, so I guess that's the \
difference.

To summarize, I need to be able to pass connection info/userid/password directly via \
the VBA code so I am able to run the code successfully.

--- Code

Option Explicit
Public Application
Public Project
Public sasProgram
Public log1 As String

Sub Example2()
    Dim x
    x = Time()
    Set Application = CreateObject("SASEGObjectModel.Application.7.1")
    Application.PromptForCredentials = True
    ' Assign the server and profile - Here's where the error pops up
    Application.SetActiveProfile ("Grid")
    ' Create a new EG project
    Set Project = Application.New
    ' Create a new code of Code Collection
    Set sasProgram = Project.CodeCollection.Add
    ' Assign output options
    sasProgram.UseApplicationOptions = False
    sasProgram.GenListing = True
    sasProgram.GenSasReport = False
    ' Select the server
    sasProgram.Server = "SASApp"
    ' Get current XLS path (VBA is being run from Excel)
    Dim DatafileDir As String
    DatafileDir = ThisWorkbook.Path
    ' Set the Hello World code
    sasProgram.Text = "data test; set work._prodsavail; run;"
    ' Run the code
    sasProgram.Run
    ' Save log to file and display in msgbox
    sasProgram.Log.SaveAs "C:\Documents and Settings\C109033\Escritorio\script1.log"
    log1 = sasProgram.Log.Text
    MsgBox sasProgram.Log.Text
    ' Show elapsed time in msgbox
    x = Time() - x
    MsgBox x
End Sub


--- Error

SAS.EG.Scripting.ScriptingException: Connection to XXX.XXX.XXX.XXX:8561 requires \
valid credentials (userid and password).


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic