× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Has anyone been able to successfully use the ProfileTokenCredential to
change user profiles within a Java program on the 400?  I am using the
following code with no luck:
 
  // Prepare to work with the local AS/400 system.
      AS400 system = new AS400("localhost", "*CURRENT", "*CURRENT");
 
      // Create a single-use ProfileTokenCredential with a 60 second
timeout.
      // A valid user ID and password must be substituted.
      ProfileTokenCredential pt = new ProfileTokenCredential();
      try {
   pt.setSystem(system);
      pt.setTimeoutInterval(60);
      pt.setTokenType(ProfileTokenCredential.TYPE_SINGLE_USE);
 
      pt.setTokenExtended(username.trim(), password.trim());

      // Swap the OS/400 thread identity, retrieving a credential to
      // swap back to the original identity later.
      AS400Credential cr = pt.swap(true);
      // Perform work under the swapped identity at this point.
 
      System.out.println("Changed to user " + username.trim());
 
      // Swap back to the original OS/400 thread identity.
      cr.swap();
 
   } catch (PropertyVetoException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
   } catch (AS400SecurityException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
   } catch (Exception e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
   }
 
       // Clean up the credentials.
       try {
    cr.destroy();
    } catch (AS400SecurityException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
    } catch (Exception e) {
    }
 
       try {
    pt.destroy();
    } catch (AS400SecurityException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
    } catch (Exception e) {
    }
 
=======================================
Mike Silvers, Chief Operating Officer
Hainey Business Systems-Division of Affinigent, Inc
IT Solutions for Business Performance

Cell: (717) 324-5508
Phone:  (717) 600-0033 ext 106
Fax: (877) 804-9589
http://www.affinigent.com <http://www.affinigent.com/> 
http://www.hbs-inc.com <http://www.hbs-inc.com/> 
AIM:  IBMJavaMan
Skype: hbs_mike_silvers
=======================================
 

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.