0

In CS file I used this code and it's worked:

  SPWeb site = SPContext.Current.Web;
        int managerGroup = site.Groups["Właściciele witryny Main"].ID;
        if (site.IsCurrentUserMemberOfGroup(managerGroup))

How use in event receiver? Please help.

Grzegorz Z
  • 1,709
  • 7
  • 42
  • 73

2 Answers2

1

I done this like the same method but with direct url:

        public bool sprawdzanieUserow()
    {
        SPSite oSiteCollection = new SPSite("http://aaaa/");
        SPWeb site = oSiteCollection.RootWeb;
        int managerGroup = site.Groups["Właściciele witryny Main"].ID;
        if (site.IsCurrentUserMemberOfGroup(managerGroup))
        {
            return true;
        }
        return false;
    }
Grzegorz Z
  • 1,709
  • 7
  • 42
  • 73
-2

'After' Event receivers are launched by system account and therefore you cannot get the current user from its context.

You should check these : http://social.msdn.microsoft.com/Forums/en/sharepointdevelopmentlegacy/thread/53c64bb1-6810-48ac-910a-9faa16c8e3b9

How to get current logged user in event receivers?

sle1306
  • 67
  • 3