locked
Get AD Group Member SPGroup RRS feed

  • Question

  • Hi All,

    I have added an AD Group in our SP Site. How can I get an AD Group Member SharePoint Group?

    SPContext.Current.Web.CurrentUser can't get, i think it's because the AD Group is added in the SP Site and not the current user that is a member  of an added AD Group.


    • Edited by I.Alt.Tab Monday, April 8, 2013 1:38 AM
    Thursday, April 4, 2013 5:47 AM

Answers

  • try below things both are different 

    1)SPFieldUserValue objUserFieldValue = new SPFieldUserValue(properties.Web, properties.AfterProperties["Name"].ToString());

                        objUser = objUserFieldValue.User;

    2) 

    Spweb spWebObject;

    SPGroup spGroup = spWebObject.SiteGroups["SPGROUP1"];

    spGroup.Users

    • Proposed as answer by Hemendra Agrawal Thursday, April 11, 2013 12:24 PM
    • Marked as answer by Qiao Wei Sunday, April 14, 2013 1:22 PM
    Tuesday, April 9, 2013 12:20 PM

All replies

  • Hi,

    I am little bit confuse for your question.But I want to tell Ad group member and sharepoint member group is totally difeerent.you can map both member with user.

    So if want to get Ad group member for particular Ad group ,you need to DirectoryEntry object.

    you can it from google.

    i dont know this is really looking for you.

    if you are looking for some different things let me know it.ok

    Thursday, April 4, 2013 6:04 AM
  • I'm looking for the SPGroup.

    Sample Scenarion:

    ADGroup1 is added in SPSITE1 as member of SPGROUP1
    ADGroup1 members: MEMBER1 and MEMBER2
    Now in the site, when MEMBER1 is currently logged in the SPContext.Current.Web.CurrentUser is equal to MEMBER1.
    Now I want to get MEMBER1 SPGroup not the AD Group

    User = MEMBER1
    Expected Output (SPGroup) = SPGROUP1

    Thursday, April 4, 2013 8:16 AM
  • try below things both are different 

    1)SPFieldUserValue objUserFieldValue = new SPFieldUserValue(properties.Web, properties.AfterProperties["Name"].ToString());

                        objUser = objUserFieldValue.User;

    2) 

    Spweb spWebObject;

    SPGroup spGroup = spWebObject.SiteGroups["SPGROUP1"];

    spGroup.Users

    • Proposed as answer by Hemendra Agrawal Thursday, April 11, 2013 12:24 PM
    • Marked as answer by Qiao Wei Sunday, April 14, 2013 1:22 PM
    Tuesday, April 9, 2013 12:20 PM