Jump to content
Sign in to follow this  
Andreas_Hoffmann

CDS Add/Remove User Groupmapping

Recommended Posts

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

 

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use and have taken note of our Privacy Policy.
We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.