ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Retrieving Information from userprofile or group of profiles - QSYRUSRI

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Retrieving Information from userprofile or group of profiles - QSYRUSRI

    Procedure to return a hunk of info on userid


    procedure
    PHP Code:
         H NOMAIN EXPROPTS(*RESDECPOS)                                                                  
          * 
    Beginning of procedure                                                                      
                                                                                                        
          
    /COPY SOURCE,USRDATA_CP                                                                       
                                                                                                        
         P usrdata         B                   EXPORT                                                   
                                                                                                        
          
    *------------------------------------------------                                             
          **  
    E N T R Y   P A R M S                      **                                             
          *------------------------------------------------                                             
                                                                                                        
         
    d usrdata         pi              n                                                            
         d  inUser                       10a   
    const                                                    
                                                                                                        
         
    d $GetUsrInf      PR                  ExtPgm('QSYRUSRI')                                       
         
    d   RcvVar                      53                                                             
         d   RcvVarLen                   10i 0                                                          
         d   Format                       8    
    const                                                    
         
    d   UserPrf                     10    const                                                    
         
    d   Error                        1    const                                                    
                                                                                                        
         
    d Count           s             10i 0                                                          
         d Receiver        s           1000    inz
    (' ')                                                 
         
    d Start           s             10i 0                                                          
         d VarLength       s             10i 0 inz
    (1000)                                                
         
    d ValidProfile    s               n   inz('1')                                                 
         
    d Work10          s             10                                                             
                                                                                                        
          
    /free                                                                                         
                                                                                                        
           $GetUsrInf
    (ProfileData :VarLength:'USRI0300':'*CURRENT':' ');                                
           if  
    ProfileData.BytesReturned <= *zeros;                                                     
            
    ValidProfile = *off;                                                                        
           else;                                                                                        
                                                                                                        
            
    Start ProfileData.Offset2SupGrp;                                                          
            for 
    count 1 to ProfileData.NumbSupGrps;                                                   
             
    work10 = %trim(%subst(ProfileData:Start:10));                                              
             
    MySuppGroups(count) = %trim(%subst(ProfileData:Start));                                    
             
    start+=10;                                                                                 
            endfor;                                                                                     
                                                                                                        
           endif;                                                                                       
           return  
    ValidProfile;                                                                        
                                                                                                        
          /
    end-free                                                                                     
                                                                                                        
         P usrdata         E 
    Copy book
    PHP Code:
                                                                                                        
          
    USRDATA_CP Get user profile information                                                   
                                                                                                        
         d USRDATA         pr              n                                                            
         d  inUser                       10a   
    const                                                    
                                                                                                        
          
    //                                                                                            
          // Program Info                                                                               
          //                                                                                            
         
    d                SDS                                                                           
         d  
    @PGM                   1     10                                                             
         d  
    @PARMS                37     39  0                                                          
         d  
    @MSGDTA               91    170                                                             
         d  
    @MSGID               171    174                                                             
         d  
    @JOB                 244    253                                                             
         d  
    @USER                254    263                                                             
         d  
    @JOB#                264    269  0                                                          
                                                                                                        
         
    **-- UserProfile Data                                                                          
         d ProfileData     ds                  Qualified                                                
         d  BytesReturned                10i 0                                                          
         d  BytesAvail                   10i 0                                                          
         d  Profile                      10a                                                            
         d  PreviousSO                   13a                                                            
         d  Reserved1                     1a                                                            
         d  InvalidSO
    #                   10i 0                                                          
         
    d  Status                       10a                                                            
         d  PWChageDate                   8a                                                            
         d  NoPassword                    1a                                                            
         d  Reserved2                     1a                                                            
         d  PWExpInt                     10i 0                                                          
         d  PWExpDate                     8a                                                            
         d  PWDaysToEXP                  10i 0                                                          
         d  SetPW2Exp                     1a                                                            
         d  UserClass                    10a                                                            
         d SpecialAuth                   15a                                                            
         d GroupProfile                  10a                                                            
         d Owner                         10a                                                            
         d GroupAuthority                10a                                                            
         d AssitanceLevel                10a                                                            
         d CurrentLib                    10a                                                            
         d InitalMenu                    10a                                                            
         d InitalMenuLib                 10a                                                            
         d InitalPgm                     10a                                                            
         d InitalPgmLib                  10a                                                            
         d LimitCap                      10a                                                            
         d TextDesc                      50a                                                            
         d DspSignOnInf                  10a                                                            
         d LimitSessions                 10a                                                            
         d KeyBoardBuff                  10a                                                            
         d Reserved3                      2a                                                            
         d  MaxStorage                   10i 0                                                          
         d  StorageUsed                  10i 0                                                          
         d HighestSchd                    1a                                                            
         d JobDesc                       10a                                                            
         d JobDescLib                    10a                                                            
         d AccountCode                   15a                                                            
         d MsgQ                          10a                                                            
         d MsgqLib                       10a                                                            
         d MsgqDelv                      10a                                                            
         d Reserved4                      2a                                                            
         d MsgqSev                       10i 0                                                          
         d OutQ                          10a                                                            
         d OutqLib                       10a                                                            
         d PrintDev                      10a                                                            
         d SpecialEnv                    10a                                                            
         d AttnPgm                       10a                                                            
         d AttnPgmLib                    10a                                                            
         d Language                      10a                                                            
         d Country                       10a                                                            
         d CharCode                      10i 0                                                          
         d UserOpts                      36a                                                            
         d SortSeqTbl                    10a                                                            
         d SortSeqTblLib                 10a                                                            
         d ObjectAudVal                  10a                                                            
         d UserActAudLvl                 64a                                                            
         d GrpAuthType                   10a                                                            
         d Offset2SupGrp                 10i 0                                                          
         d NumbSupGrps                   10i 0                                                          
         d UserID
    #                       10i 0                                                          
         
    d GroupID#                      10i 0                                                          
         
    d OffsetHomeDir                 10i 0                                                          
         d LengthHomeDir                 10i 0                                                          
         d LocalJobAtrb                  16                                                             
         d OffsetLocPath                 10i 0                                                          
         d LengthLocPath                 10i 0                                                          
         d GroupMbrInd                    1                                                             
         d DigitalCert                    1                                                             
         d CharIDCntrl                   10                                                             
         d OffsetASPUsge                 10i 0                                                          
         d NbrASPStgUsgD                 10i 0                                                          
         d NbrASPStgUsgDR                10i 0                                                          
         d LenASPStgUsgDR                10i 0                                                          
         d Reserved5                      2a                                                            
         d MoreInfo                     200                                                             
                                                                                                        
         d MySuppGroups    s             10    dim
    (100)                                                 
         
    d MyHomeDir       s            256    varying 

    compile the above crap:
    Code:
    CRTRPGMOD MODULE(JAMIELIB/USRDATA) SRCFILE(JAMIELIB/SAVSRC)

    example of using:
    PHP Code:
    d badProfile      s               n                                           
    d Profile         s             10    inz
    ('FLANARY')                          
                                                                                  
     /
    copy qprcsrc,usrdata_CP                                                     
                                                                                  
     
    * ================================================                           
     * 
    M A I N   L I N E                                                          
     
    * ================================================                           
     *                                                                            
     /
    free                                                                        
                                                                                  
          badProfile 
    usrdata(Profile);                                          
          *
    inlr = *on;                                                            
                                                                                  
     /
    end-free 
    compile the above crap:
    Code:
    CRTRPGMOD MODULE(JAMIELIB/USERDTATST) SRCFILE(JAMIELIB/SAVSRC)
    Then
    Code:
    crtpgm JAMIELIB/USERDTATST module(userdtatst usrdata)
    Attached Files
    All my answers were extracted from the "Big Dummy's Guide to the As400"
    and I take no responsibility for any of them.

    www.code400.com
Working...
X