Need help: Client Principal Creation

Posted by dthazhat on 17-Apr-2012 07:01

Is there anyone who could help me with the client principal creation?
Here’s the sample code I am using. Can anyone tell me what I should do to make this code work? (I just started learning OpenEdge and ABL)
My database name is “sportsmt” and I have the “CreateSession.p” in the appserver folder of my OpenEdge workspace. The databse is multitenant and has got tenants, domains, and users.
Pleaseee help..
ROUTINE-LEVEL ON ERROR UNDO, THROW.

DEFINE VARIABLE hServer             AS HANDLE NO-UNDO.
DEFINE VARIABLE hCPObject           AS HANDLE NO-UNDO.
DEFINE VARIABLE kUser               AS CHARACTER NO-UNDO.
DEFINE VARIABLE kPwd                AS CHARACTER NO-UNDO.
DEFINE VARIABLE kDomain             AS CHARACTER NO-UNDO.
DEFINE VARIABLE lOK                 AS LOGICAL NO-UNDO.
DEFINE VARIABLE kMessage            AS CHARACTER NO-UNDO.
DEFINE VARIABLE rObject             AS RAW NO-UNDO.

SECURITY-POLICY:LOAD-DOMAINS("sportsmt").

UPDATE
    kDomain FORMAT "x(10)" LABEL "Domain"
    kUser FORMAT "x(20)" LABEL "UserID"
    kPwd FORMAT "x(20)" LABEL "Password" BLANK
    WITH 1 COL SIDE-LABELS .

ASSIGN
    lOK = FALSE
    kMessage = ""
    rObject = ? .    

CREATE SERVER hServer.
hServer:CONNECT ('-AppService AuthSession') NO-ERROR.

IF hServer:CONNECTED() THEN DO:

    MESSAGE "connection established"
    VIEW-AS ALERT-BOX.
    RUN createSession.p ON hServer (INPUT kUser + "@" + kDomain,
                                    INPUT kPwd,
                                    INPUT SESSION:CLIENT-TYPE,
                                    OUTPUT lOK,
                                    OUTPUT kMessage,
                                    OUTPUT rObject).
    IF lOK THEN DO:
        CREATE CLIENT-PRINCIPAL hCPObject.
        hCPObject:IMPORT-PRINCIPAL(rObject).  

        IF NOT SECURITY-POLICY:SET-CLIENT(hCPObject) THEN DO:
            MESSAGE "Client Principal Object is not good" VIEW-AS ALERT-BOX.
        END.        

    END.                             

    ELSE
        MESSAGE kMessage
        VIEW-AS ALERT-BOX.
    hServer:DISCONNECT().  
END.

ELSE
    MESSAGE 'Could not establish connection to appserver'
    VIEW-AS ALERT-BOX.   

FINALLY:

    IF VALID-HANDLE(hServer) THEN DELETE OBJECT hServer NO-ERROR.
    IF VALID-HANDLE (hCPObject) THEN DELETE OBJECT hCPObject NO-ERROR.
    ASSIGN
        hServer = ?
        hCPObject = ?. 
END.
And, here's the error message..
Error1 (2).png


All Replies

Posted by dthazhat on 17-Apr-2012 07:29

I was referring the documents available in Progress community (http://communities.progress.com/pcom/docs/DOC-107262). I was able to make the sample code work, but no idea how to make this one work.

Posted by Michael Jacobs on 17-Apr-2012 07:36

The error suggests that the problem is with the AppServer connection, not the Client-Principal.   I would suggest getting the error information in ERROR-STATUS after you execute hSrv:CONNECT(...),  that may have clues to what is missing.  Also, make sure you have configured the "AuthSession" AppServer service, started the AppServer, and verified the "AuthSession"  AppServer is running using asbman utility.   When the AppServer connection is good - then output the ERROR-STATUS handle if the hCP:IMPORT-PRINCIPAL() fails.

Posted by dthazhat on 18-Apr-2012 06:01

Thanks Michael.

I am able to connect to the appserver now, but still, not able to get the Client Principal created. It ends the procedure once the appserver connection is established.

Posted by Michael Jacobs on 18-Apr-2012 06:52

So you get the "connection established" message, but you do not get any

output from "MESSAGE kMessage." ?

The problem may be that createSession.p returns an error and terminates

the procedure.

You might add a MESSAGE after the RUN statement that confirms that

createSession.p completed and the values of lOK and the length of rObject.

This thread is closed