| Anves Kumar rayankula | b44c957 | 2021-04-27 00:44:06 -0500 | [diff] [blame] | 1 | *** Settings *** | 
 | 2 | Documentation  This module provides general keywords for LDAP. | 
 | 3 |  | 
 | 4 | *** Keywords *** | 
 | 5 |  | 
 | 6 | Get LDAP Configuration Using Redfish | 
 | 7 |     [Documentation]  Retrieve LDAP Configuration. | 
 | 8 |     [Arguments]   ${ldap_type} | 
 | 9 |  | 
 | 10 |     # Description of argument(s): | 
 | 11 |     # ldap_type  The LDAP type ("ActiveDirectory" or "LDAP"). | 
 | 12 |  | 
 | 13 |     ${ldap_config}=  Redfish.Get Properties  ${REDFISH_BASE_URI}AccountService | 
| George Keishing | 409df05 | 2024-01-17 22:36:14 +0530 | [diff] [blame] | 14 |     RETURN  ${ldap_config["${ldap_type}"]} | 
| Anves Kumar rayankula | b44c957 | 2021-04-27 00:44:06 -0500 | [diff] [blame] | 15 |  | 
 | 16 |  | 
 | 17 | Get LDAP Privilege And Group Name Via Redfish | 
 | 18 |     [Documentation]  Get LDAP groupname via Redfish. | 
 | 19 |  | 
 | 20 |     # Get LDAP configuration via Redfish. | 
 | 21 |     # Sample output of LDAP configuration: | 
 | 22 |     # { | 
 | 23 |     #  'RemoteRoleMapping': [ | 
 | 24 |     #    { | 
 | 25 |     #     'RemoteGroup': 'openldapgroup', | 
 | 26 |     #     'LocalRole': 'Administrator' | 
 | 27 |     #     }, | 
 | 28 |     #   ], | 
 | 29 |     #  'Authentication': | 
 | 30 |     #   { | 
 | 31 |     #    'Username': 'cn=Administrator,dc=ldap,dc=com', | 
 | 32 |     #    'Password': None, | 
 | 33 |     #    'AuthenticationType': 'UsernameAndPassword' | 
 | 34 |     #   }, | 
 | 35 |     #  'LDAPService': | 
 | 36 |     #    { | 
 | 37 |     #     'SearchSettings': | 
 | 38 |     #      { | 
 | 39 |     #       'BaseDistinguishedNames': ['dc=ldap,dc=com'], | 
 | 40 |     #       'UsernameAttribute': 'cn', | 
 | 41 |     #       'GroupsAttribute': 'gidNumber' | 
 | 42 |     #      } | 
 | 43 |     #    }, | 
 | 44 |     #  'ServiceEnabled': True, | 
 | 45 |     #  'Certificates': | 
 | 46 |     #    { | 
 | 47 |     #      '@odata.id': u'/redfish/v1/AccountService/LDAP/Certificates' | 
 | 48 |     #    }, | 
 | 49 |     #  'ServiceAddresses': ['ldap://xx.xx.xx.xx/'] | 
 | 50 |     # } | 
 | 51 |  | 
 | 52 |     ${ldap_config}=  Get LDAP Configuration Using Redfish  ${LDAP_TYPE} | 
 | 53 |     ${num_list_entries}=  Get Length  ${ldap_config["RemoteRoleMapping"]} | 
 | 54 |     Return From Keyword If  ${num_list_entries} == ${0}  @{EMPTY} | 
 | 55 |     ${ldap_group_names}=  Create List | 
 | 56 |     FOR  ${i}  IN RANGE  ${num_list_entries} | 
 | 57 |       Append To List  ${ldap_group_names}  ${ldap_config["RemoteRoleMapping"][${i}]["RemoteGroup"]} | 
 | 58 |     END | 
 | 59 |  | 
| George Keishing | 409df05 | 2024-01-17 22:36:14 +0530 | [diff] [blame] | 60 |     RETURN  ${ldap_group_names} | 
| Anves Kumar rayankula | b44c957 | 2021-04-27 00:44:06 -0500 | [diff] [blame] | 61 |  | 
| Anves Kumar rayankula | 4fa52d7 | 2021-07-04 02:37:30 -0500 | [diff] [blame] | 62 |  | 
 | 63 | Create LDAP Configuration | 
 | 64 |     [Documentation]  Create LDAP configuration. | 
 | 65 |     [Arguments]  ${ldap_type}=${LDAP_TYPE}  ${ldap_server_uri}=${LDAP_SERVER_URI} | 
 | 66 |     ...  ${ldap_bind_dn}=${LDAP_BIND_DN}  ${ldap_bind_dn_password}=${LDAP_BIND_DN_PASSWORD} | 
 | 67 |     ...  ${ldap_base_dn}=${LDAP_BASE_DN} | 
 | 68 |  | 
 | 69 |     # Description of argument(s): | 
 | 70 |     # ldap_type              The LDAP type ("ActiveDirectory" or "LDAP"). | 
 | 71 |     # ldap_server_uri        LDAP server uri (e.g. ldap://XX.XX.XX.XX). | 
 | 72 |     # ldap_bind_dn           The LDAP bind distinguished name. | 
 | 73 |     # ldap_bind_dn_password  The LDAP bind distinguished name password. | 
 | 74 |     # ldap_base_dn           The LDAP base distinguished name. | 
 | 75 |  | 
 | 76 |     ${body}=  Catenate  {'${ldap_type}': | 
 | 77 |     ...  {'ServiceEnabled': ${True}, | 
 | 78 |     ...   'ServiceAddresses': ['${ldap_server_uri}'], | 
 | 79 |     ...   'Authentication': | 
 | 80 |     ...       {'AuthenticationType': 'UsernameAndPassword', | 
 | 81 |     ...        'Username':'${ldap_bind_dn}', | 
 | 82 |     ...        'Password': '${ldap_bind_dn_password}'}, | 
 | 83 |     ...   'LDAPService': | 
 | 84 |     ...       {'SearchSettings': | 
 | 85 |     ...           {'BaseDistinguishedNames': ['${ldap_base_dn}']}}}} | 
 | 86 |  | 
 | 87 |     Redfish.Patch  ${REDFISH_BASE_URI}AccountService  body=${body} | 
 | 88 |     Sleep  15s |