WebSphere Application Server & Liberty

WebSphere Application Server & Liberty

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.

 View Only
  • 1.  Retrieving username in wsadmin scripts

    Posted Wed June 13, 2012 08:00 AM
    Hi

    We have a requirement in WSADMIN where we need to pass username as a parameter to an MBean invocation. The user is logged in to the wsadmin shell. The user can choose any of the possible ways to log in. He can pass his username through command line, properties file or any other way which exists. We have to cover all cases.

    Is there any API which can be used? Is there any variable which gets populated that store username and can be used? Does either of these options exist?

    Thanks
    Parimal


  • 2.  Retrieving username in wsadmin scripts

    Posted Wed June 13, 2012 09:53 AM
    Hi Parimal,

      I don't understand very well but do you want something like this?

      Example 1:
      =========
      www.coderanch.com/t/424670/Jython-Python...
     
        import java.util as util
        import java.io as javaio

        properties = util.Properties()
        #add try catch for this
        propertiesfis =javaio.FileInputStream("wasconfig.properties")
        properties.load( propertiesfis)

      Example 2:
      ==========
      fixunix.com/websphere/207071-using-jytho...
     
        # This is just to load properties file
        import java.util as util
        import java.io as javaio
        import sys

        props = util.Properties()
        propfile_name=sys.argv[0]
        print "File name ", propfile_name
        inside = props.load(javaio.FileInputStream(propfile_name))
        # get the value from properties file
        clusName=props.getProperty("clusName")
        
        Hope this helps,
        
    regards,


  • 3.  Retrieving username in wsadmin scripts

    Posted Thu June 14, 2012 03:47 AM
    I will frame the question differently to make it clearer.

    We have a requirement in WSADMIN where we need to pass the logged-in username as a parameter to an MBean invocation inside the script. In WLST, there is a variable named ‘username’ which I can use directly inside my script.  I am looking for a similar kind of variable in WSADMIN, but I couldn’t find out the corresponding variable in WSADMIN.  Is there any API available, which can be used to retrieve the logged-in user name?  

    Please note that the user has multiple ways to log in into WSADMIN shell. For ex. he can pass his username through command line, properties file, stdin, GUI prompt or any other way which exists. Whichever way the user logs-in, we need to be able to get the user name inside the script (irrespective of the methodology used to login). 

    Thanks,
    Parimal



  • 4.  Retrieving username in wsadmin scripts

    Posted Thu June 14, 2012 06:49 PM
    Hi Parimal,

      in admin console you can know which users are logged (ond logout too), so if you enable wsadmin login in admin console (in preferences) sure that you can get logged usernames.

      I'm reviewing the API Iguess that you can get the username.

      I tell you.

    regards


  • 5.  Retrieving username in wsadmin scripts

    Posted Tue June 19, 2012 04:32 AM
    Hi Gabriel

    Let me know if you found any API or any other fix.

    Thanks
    Parimal