Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • MK 429 posts 906 karma points
    Mar 25, 2012 @ 16:10
    MK
    0

    Get Members By Group

    Hi there,

    I know this has been addressed few times in this forum but I can't really get the information Im looking for.

    I would like to get the member details according to group.

    I used the following as suggested before:

     

    foreach (var userInRole in Roles.GetUsersInRole("Supplier")) {
      var user = new MembershipUser(userInRole);
    }

    Or,

    var user = Membership.GetUser(userInRole);

     

    But this does not give me the required properties such as custom property.

    I can get the required information via MemberGroup.GetByName("Supplier").GetMembers();

    but it is an obsolete class.

    Any idea?

    Many thanks

    mkariti

     

     

     

     

  • Lee Kelleher 4026 posts 15836 karma points MVP 13x admin c-trib
    Mar 25, 2012 @ 19:21
    Lee Kelleher
    1

    Hi mkariti,

    Use the "MemberGroup.GetByName" and ignore the obsolete class.  I know the reason why it was obsoleted, but IMHO it was overkill in doing so - since there isn't a MembershipProvider API that gives you what you need.

    If you are really bothered by the Visual Studio warning messages about it, then you can wrap your code in the following directives:

    #pragma warning disable 0618
    #pragma warning restore 0618

    Cheers, Lee.

  • MK 429 posts 906 karma points
    Mar 25, 2012 @ 20:38
    MK
    0
    Hi Lee,
    I'm not worried with the VS warning as I'm worried with class being obsolete. 
    Many thanks for your reply was very helpful
    mkariti
     
  • Lee Kelleher 4026 posts 15836 karma points MVP 13x admin c-trib
    Mar 25, 2012 @ 20:43
    Lee Kelleher
    0

    Hi mkariti,

    Have no fear, those methods are used internally by the MembershipProvider, so they should always be around.

    Cheers, Lee.

     

Please Sign in or register to post replies

Write your reply to:

Draft