Author Topic: Cannot remove person from Access Group  (Read 1170 times)

Offline dp5000

  • Newbie
  • *
  • Posts: 2
  • Karma: 0
Cannot remove person from Access Group
« on: November 16, 2023, 07:10:23 PM »
Resorting to actually asking for insight via forum, lol...

Genesys Configuration Server version 8.5.101.92.  (I believe our SDK is still 8.1.300.50)

Been trying to code simple logic to remove a person from one or more Access Groups.  We've already got existing, working logic to add persons to Access Groups, and for the new remove logic, we're using the same person objects and access group objects, so not sure why remove doesn't work.

Nothing tried has worked, but I also see no helpful error messages letting me know why (E.g. permissions, objects don't exist, etc).

Mainly have been attempting to remove a person from an access group with the following:

[code]
                        CfgID personToRemove = new CfgID(mConfService, person)
                        {
                          DBID = person.DBID,
                          Type = CfgObjectType.CFGPerson
                        };

                        var result = accessGroup.MemberIDs.Remove(personToRemove);
                        if (result)
                        {
                            accessGroup.Save();
                            Log.Debug("Updated profile " + person.UserName.ToString() + ". Removed access group: " + grp + "(" + dbidNumber + ")");
                        }
                        else
                        {
                            Log.Debug("Did not update Profile " + person.UserName.ToString() + ". Could not remove profile from access group: " + grp + "(" + dbidNumber + ")");
                        }
[/code]

It always goes to "Did not update Profile" [[i]sic[/i] - I know we're updating the Access Group at this stage].

-----
When that approach never worked, after many attempts and variations, discovered another method in the CfgAccessGroup Class, called RemoveAccount().  Tried that (below), but no luck there either.

[code]
                            var person = FindByUserName(profileData.UserName);
                            accessGroup.RemoveAccount(person, false);
                            accessGroup.Save();
                            Log.Debug("Updated profile " + person.UserName.ToString() + ". Removed access group: " + grp + "(" + dbidNumber + ")");
[/code]

-----

API user has Super Administrator role, so allegedly has Full Control over access groups, etc.  Have tried going through Config Server Proxy, but also directly to main Config Server.

Any advice on the matter would be greatly appreciated.  ???  ::)

Offline cavagnaro

  • Administrator
  • Hero Member
  • *****
  • Posts: 7639
  • Karma: 56330
Re: Cannot remove person from Access Group
« Reply #1 on: November 19, 2023, 06:06:49 PM »
Usually I do it via CME and check logs to see what was executed. Then go to code and try to replicate the same.

Enviado de meu SM-S918B usando o Tapatalk


Offline PeteHoyle

  • Full Member
  • ***
  • Posts: 126
  • Karma: 13
Re: Cannot remove person from Access Group
« Reply #2 on: November 20, 2023, 02:47:24 PM »
Hi,

I had a quick play around, and at the moment the only way I could find to remove a person from the access group was using this code:

[code]

                        CfgID idToRemove = null;
                        foreach (CfgID id in accessGroup.MemberIDs)
                        {
                            if(id.DBID == cfgPersonToRemove.DBID)
                            {
                                idToRemove = id;
                            }
                        }


                        if (idToRemove != null)
                        {
                            var res = accessGroup.MemberIDs.Remove(idToRemove);
                            log.Debug($"Result of Remove Member: {res}");
                            accessGroup.Save();
                        }

[/code]

Offline dp5000

  • Newbie
  • *
  • Posts: 2
  • Karma: 0
Re: Cannot remove person from Access Group
« Reply #3 on: November 20, 2023, 05:40:41 PM »
Pete,

Hmm. Interesting.. I guess I'll try that approach. Perhaps it's using a different id that way.