ARTIFACTORY: How to import LDAP group using REST API

ARTIFACTORY: How to import LDAP group using REST API

AuthorFullName__c
Prakriti Vishwakarma
articleNumber
000006138
ft:sourceType
Salesforce
FirstPublishedDate
2024-07-07T10:04:02Z
lastModifiedDate
2024-07-07
VersionNumber
2

If the LDAP group is created in the LDAP server, generally in order to add the LDAP group, you would need to sync the LDAP group from the Artifactory UI by clicking the “import” button. 
If you would like to import the LDAP group using the REST API, you may follow the below steps to achieve the same. 

1. Create a group in the LDAP server- “igroup1” and add users to it.

User-added image

2. Check the status of the LDAP groups under the Synchronised LDAP groups section [click the search icon to get the list of LDAP groups]. Refer to the below screenshot. 

User-added image

3. In order to import the groups using REST API, create a .json file for the group. I have used group.json
    group.json-

{
  "name" : "igroup1",
  "autoJoin" : true,
  "realm" : "ldap",
  "realmAttributes" : "ldapGroupName=igroup1;groupsStrategy=STATIC;groupDn=cn=igroup1,ou=users,dc=example,dc=com",
  "adminPrivileges" : false,
  "policyManager" : false,
  "watchManager" : false,
  "reportsManager" : false
}

4. Use the Create or Replace Group API to import the LDAP group. Here is a sample output -

curl -XPUT -u<adminuser>:<passowrd>
https://Artifactory.com/artifactory/api/security/groups/igroup1 -H "content-type: application/json" -T group.json

5. You would see that the group has been successfully imported to the Artifactory.

User-added image