代码之家  ›  专栏  ›  技术社区  ›  Konrad

在jython中将控制台用户添加到WebSphere

  •  0
  • Konrad  · 技术社区  · 16 年前

    我需要使用Jython脚本将管理用户添加到WebSphere控制台。我试图打开“logcommandassistancecommands”首选项,但是它没有记录添加用户。但它确实记录了其他东西。

    我们设置了很多服务器,并试图编写整个安装过程的脚本。

    干杯, 康拉德

    1 回复  |  直到 16 年前
        1
  •  4
  •   Cjxcz Odjcayrwl    13 年前

    def dbAuthenticationAlias():
       print 'Create JAAS - J2C Authentication Alias'
    
       #--------------------------------------------------------------
       # Check if JAAS - J2C Authentication Alias exists
       #--------------------------------------------------------------
    
       global dbuseralias
    
       # generate user alias
       dbuseralias = nodeName + '/' + dbuser
    
       # get context 
       sec = AdminConfig.getid('/Cell:%s/Security:/' % cellName)
    
       #Get all J2C Authentication Aliases (they are separated by \n
       j2c = AdminConfig.list('JAASAuthData',sec)
    
       found = 0
       if len(j2c) > 0 :
          for j2cUserId in j2c.splitlines():
             if AdminConfig.showAttribute(j2cUserId,"alias") == dbuseralias:
                found = 1
    
       #--------------------------------------------------------------
       # Create a JAAS - J2C Authentication Alias
       #--------------------------------------------------------------
       if found == 0 :
          print 'user not found, creating'
    
          # create structure for J2C Authentication Alias
          jaasAttrs = [['alias', dbuseralias],['userId', dbuser],['password',dbpassword]]  
    
          #create J2C Authentication Alias
          AdminConfig.create('JAASAuthData', sec, jaasAttrs)
    
          print 'user %s created' % dbuseralias
    
          #saving
          adminConfigSave()
       else:
          print 'user found'
    

    到目前为止,我遇到了一些问题,找到了一个具体的设置。因此,我使用wsadmin工具中的以下命令检索当前配置。

    sec = AdminConfig.getid('/Cell:%s/Security:/' % cellName)
    #shows all attributes for the config element given by an ID 
    print AdminConfig.show(sec) 
    #shows all attributes and expands the attributes where necessary 
    print AdminConfig.showall(sec) 
    

    除了检索安全设置之外,您还可以检索服务器设置,然后在配置树中进行更深入的操作。

    srv = AdminConfig.getid('/Node:%s/Server:%s/' % (node,server)) 
    #get the process definition from server config 
    prcDef = AdminConfig.list('ProcessDef',srv) 
    #get JVM config from process definition 
    jvm= AdminConfig.list('JavaVirtualMachine',prcDef)