在 jython 中向 WebSphere 添加控制台用户

发布于 2024-08-20 16:31:15 字数 138 浏览 2 评论 0原文

我需要使用 Jython 脚本将管理用户添加到 WebSphere 控制台。我尝试打开“记录命令辅助命令”首选项,但它没有记录添加用户。但它确实记录了其他内容。

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

干杯, 康拉德

I need to add Administrative users to the WebSphere Console using a Jython script. I tried to turn on the "Log command assistance commands" preference, but it did not log adding a user. It did log other stuff though.

We setup alot of servers and are trying to script the entire setup process.

Cheers,
Konrad

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

望喜 2024-08-27 16:31:15

我没有做管理用户,但是,我做了JAAS用户。按照脚本执行,它可能会为您提供足够的提示,告诉您如何执行此操作。

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) 

I haven't done the administrative user, however, I have done a JAAS user. Following the script, it might give you enough hints on how to do it.

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'

I had problems so far, finding, where a specif setting is to be made. So I used following commands within wsadmin tool to retrieve the current configuration.

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) 

Instead of retrieving the security settings you can also retrieve the server settings and subsequently moving deeper in the configuration tree.

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) 
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文