views:

644

answers:

3

Hi,

I'm actual looking for a way to get notified about any changes on a SharePoint group. First I though I would be able to this by attaching a event handler to some kind of group list. But unfortunately there are no such list representing SharePoint groups.

My second attempt was to bind a event handler to the content type SharePointGroup but this didn't work either.

So are there any other options to get notified about events on a SharePoint group?

Bye, Flo

EDIT:

Thanks for the reply so far.

I forgot to mention that I've already googled and read about the user information list. Sorry.

First I found a forum entry where they post the relative URL to the user information list (_catalogs/users/simple.aspx). When I'm using this link to see the list,it only contains users and no groups. I don't know but perhaps this link does some filtering on the list.

The other information I found about in several blog and forum posts was that a event handler attached to the user information list are not fired up on an events. I have to admit after reading that it doesn't work so many times and even on MSDN (http://msdn.microsoft.com/en-us/library/aa979520.aspx), I didn't try it on my own.

The problem attaching the event handler to the content type wasn't the attaching thing, the handler simply didn't get fired when I for example changed a group name or deleted a user from the group. I don't have an idea why the handler doesn't get called I pretty sure I implemented the right methods and attached them to the right events.

Any other suggestions how to get informed about changes on SharePoint groups?

+1  A: 

What do you mean there is no such list for SharePoint groups? You have the User Information List in which both users and SharePoint groups reside. You can attach event receivers there and filter on the items. For example you can filter on the content type id of SharePoint groups, which is 0x010b.

Also, attaching event receivers to SharePoint groups should be possible. What didn't work?

.b

Bjørn Furuknap
A: 

Hi Even im trying the same attaching the eventhandler to the spgroup but dint work any help will be truly appreciated

Thanks Arun Nehru

Nehru Arun Kumar
If you have a follow-up question you should better ask it as a new question, not post it as an answer. More people would see it that way and would try to answer. The "Ask Question" button is in the top right.
sth
+1  A: 

It is really annoying that adding or removing from a group doesn't have an event handler the best work around I have found using Google! is to turn on auditing.

Then periodicaly loop through the audit to fire my event.

            wssQuery = new SPAuditQuery(site);
            wssQuery.AddEventRestriction(SPAuditEventType.SecGroupMemberAdd);
            wssQuery.AddEventRestriction(SPAuditEventType.SecGroupMemberDel);
            wssQuery.SetRangeStart(startTime.AddMinutes(-16));
            auditCol = site.Audit.GetEntries(wssQuery);




            foreach (SPAuditEntry entry in auditCol)
            {
                    xml.LoadXml("<event>" + entry.EventData + "</event>");

                    int userId = Int32.Parse(xml.SelectSingleNode("/event/user").InnerText);
                    int groupId = Int32.Parse(xml.SelectSingleNode("/event/groupid").InnerText);

                    if (entry.Event == SPAuditEventType.SecGroupMemberAdd)
                    {
                       // Do Stuff
                    }

                    if (entry.Event == SPAuditEventType.SecGroupMemberDel)
                    {
                        // Do Stuff
                    }


             }

It does cause a serious delay between the member being added to the group and the event firing though!

I couldn't find an event handler on the audit either so the only option seems to be looping through.

This is expensive for me as we have hundreds of site collections!

Dave Cornall