1

We have developed a job that syncs information from Active Directory group onto SharePoint groups.
The job runs everyday and pulls new users added onto Active directory group,

I wanted to know if there is way I can show recently added people from SharePoint Group. Sharepoint group does not allows to create views.

Any thoughts/ideas?

Thanks in advance

2
  • "developed a job that syncs information from Active Directory group onto SharePoint groups" - so you developer the User Profile Synchronization Service. Hat tip to you :-)
    – Dennis G
    Commented Feb 14, 2013 at 20:06
  • Moontear, thanks for your compliments :) we had a specific business requirement.... :) Commented Feb 19, 2013 at 20:27

1 Answer 1

1

SharePoint does not automatically record the time and date a user was added to a SharePoint group. As you can see the SPGroup does not have a "LastModified" date or something like that - the SPUser does neither for that matter.

You have two options to get the recently added users to a SharePoint group:

  1. You can use SPAudit to generate an event when a user is added to a group, like so (as explained here):

    using (SPSite site = new SPSite("url"){
    
            SPAuditQuery auditQuery;
            SPAuditEntryCollection auditCol;
    
            auditQuery = new SPAuditQuery(site);
            auditQuery.AddEventRestriction(SPAuditEventType.SecGroupMemberAdd);
    
             // SecGroupMemberAdd: Addition of a new member to a group that is associated with a SharePoint site collection
            //Also some Enum type for group:
            //SecGroupCreate/SecGroupDelete/SecGroupMemberAdd/SecGroupMemberDel
    
            auditCol = site.Audit.GetEntries(auditQuery);
    
            foreach (SPAuditEntry entry in auditCol)
            {
                 //Execute send mail action here
            }
        }
    
  2. Check the SharePoint database. This is not recommended by Microsoft, but it certainly doesn't hurt to take a peek. The database contains the usual columns like LastModified and CreatedOn so you check which users where added when.

2
  • How do I specify if I need to audit only a specific group and not all the security group Commented Feb 19, 2013 at 20:30
  • Not possible. If you look at the SPAuditQuery class (msdn.microsoft.com/en-us/library/ms435524.aspx) you have these methods: AddEventRestriction, RestrictToList, RestrictToUser, RestrictToListItem if it helps restricting the query to a list I would do it, but you can't restrict it to only audit one SPGroup - you will have to do an if in your code.
    – Dennis G
    Commented Feb 20, 2013 at 9:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.