Andreas_Hoffmann Posted August 31, 2020 #1 Share Posted August 31, 2020 Hi, my following funktion working fine: Public Shared Sub AddUser(Group As String, User As String) Dim GroupToConfig As SWConfigDataClientLib.Proxies.Groups.GroupEntry Dim UserToConfig As SWConfigDataClientLib.Proxies.Users.UserEntry GroupToConfig = libManager.GetGroupEnum.AddUserToEnumByName(Group) UserToConfig = libManager.GetUserEnum.AddUserToEnumByName(User) Dim UserIDtoConfig As Int32 = UserToConfig.UserID Dim GroupIDtoConfig As Int32 = GroupToConfig.GroupID Dim GroupMapping As = New Proxies.Groups.MembershipEntry With { .GroupID = GroupIDtoConfig, .UserID = UserIDtoConfig, .Position = 0 } GroupToConfig.MembershipEntryCollection.Add(GroupMapping) GroupToConfig.Update(True) End Sub now I want to remove A User and have created a nearly same Sub - only the second last line is changed to GroupToConfig.MembershipEntryCollection.Remove(GroupMapping) nothing happening when I Use .RemoveAll() All Members deleted from group - but i cant remove a single User Any Idea what im doing wrong?? Im no developer an coding j4f like 30 years ago on c128d - thats why i do vb 😀 - no trace implementet yet Link to comment Share on other sites More sharing options...
Andreas_Hoffmann Posted September 2, 2020 Author #2 Share Posted September 2, 2020 This works Public Shared Sub RemoveUserFromGroup(Group As String, User As String) Dim GroupToConfig As SWConfigDataClientLib.Proxies.Groups.GroupEntry Dim UserToConfig As SWConfigDataClientLib.Proxies.Users.UserEntry GroupToConfig = libManager.GetGroupEnum.AddUserToEnumByName(Group) UserToConfig = libManager.GetUserEnum.AddUserToEnumByName(User) Dim UserIDtoConfig As Int32 = UserToConfig.UserID Dim GroupIDtoConfig As Int32 = GroupToConfig.GroupID Dim GroupList As SWConfigDataClientLib.Proxies.Groups.MembershipEntryCollection GroupList = GroupToConfig.MembershipEntryCollection Dim i As Integer = -1 For Each groupentry In GroupList i += 1 If groupentry.ToString = UserIDtoConfig.ToString & GroupIDtoConfig.ToString Then Exit For End If Next GroupToConfig.MembershipEntryCollection.RemoveAt(i) GroupToConfig.Update(True) End Sub Link to comment Share on other sites More sharing options...
Jonas_Hansen Posted December 17, 2021 #3 Share Posted December 17, 2021 Hi Andreas, may I'm totally wrong here, but I need to ask. My target is to generate a menu for internal users to add themselves or remove from a group. There for I'm using your code in the gse start block. As soon as I'm adding them there the complete rule is not working anymore. Any Idea what I'm doing wrong?? Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now