Skip to content

Commit

Permalink
fix(VOMS2CSAgent): do not change the username if a nickname is defined
Browse files Browse the repository at this point in the history
When there are multiple VOs where a user is present and there are multiple Certificates multiple dirac accounts where created for that user.
Now the nickname is always used and no index is added with new users
  • Loading branch information
andresailer committed Sep 11, 2024
1 parent 0574c0c commit 6773c43
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions src/DIRAC/ConfigurationSystem/Client/VOMS2CSSynchronizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,23 +342,26 @@ def syncCSWithVOMS(self):

# We have a real new user
if not diracName:
if nickName:
newDiracName = nickName.strip()
else:
newDiracName = self.getUserName(dn)

# Do not consider users with Suspended status in VOMS
if self.vomsUserDict[dn]["suspended"] or self.vomsUserDict[dn]["certSuspended"]:
resultDict["SuspendedUsers"].append(newDiracName)
continue

# If the chosen user name exists already, append a distinguishing suffix
ind = 1
trialName = newDiracName
while newDiracName in allDiracUsers:
# We have a user with the same name but with a different DN
newDiracName = "%s_%d" % (trialName, ind)
ind += 1
# if we have a nickname, we use the nickname no
# matter what so we can have users from different
# VOs with the same nickname / username
if nickName:
newDiracName = nickName.strip()
else:
newDiracName = self.getUserName(dn)

# If the chosen user name exists already, append a distinguishing suffix
ind = 1
trialName = newDiracName
while newDiracName in allDiracUsers:
# We have a user with the same name but with a different DN
newDiracName = "%s_%d" % (trialName, ind)
ind += 1

# We now have everything to add the new user
userDict = {"DN": dn, "CA": self.vomsUserDict[dn]["CA"], "Email": self.vomsUserDict[dn]["mail"]}
Expand Down

0 comments on commit 6773c43

Please sign in to comment.