locked
Get Sharepoint Group by username RRS feed

  • Question

  • Hi fella

    I wanna get SpGroup name from username in visual studio workflow.

    I used the following code

              SPGroupCollection grp = workflowProperties.Web.CurrentUser.Groups;        

                foreach (SPGroup group in grp)
                {
                    string groupName = group.Name;
                }

    but i always getting administrator's group.not user's.

    pls help me to solve it...

     

    Thanks

    __________

    arWINdh

    Thursday, October 21, 2010 2:36 PM

Answers

  • Try workflowProperties.OriginatorUser .

    http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.workflow.spworkflowactivationproperties.originatoruser.aspx

     

    Also see this: http://www.sharepointkings.com/2008/08/how-to-get-currently-logged-in-user-in.html

     

     


    Mike Smith TechTrainingNotes.blogspot.com
    Sunday, October 24, 2010 7:23 PM

All replies

  • Hi.

    Write the below line instead of the first line in the above code.

    SPGroupCollection GroupNames = SPContext.Current.Web.CurrentUser.Groups;

    I think this will help.

    Regards

    Ginni [My SharePoint Blog ]

    Saturday, October 23, 2010 6:19 AM
  • Hi

    I got object reference error when i have using SPContext  class. Thats y i have go for

    workflowproperties classs..

    Thanks

    ____________

    arWINdh

     

     

    Sunday, October 24, 2010 11:28 AM
  • Hi,

    Object Reference error? Why? I never got this error and I have used this several times. There must be some other reason.

    Regards

    Ginni [My SharePoint Blog]

    Sunday, October 24, 2010 5:39 PM
  • Try workflowProperties.OriginatorUser .

    http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.workflow.spworkflowactivationproperties.originatoruser.aspx

     

    Also see this: http://www.sharepointkings.com/2008/08/how-to-get-currently-logged-in-user-in.html

     

     


    Mike Smith TechTrainingNotes.blogspot.com
    Sunday, October 24, 2010 7:23 PM