Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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

share|improve this question
    
"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 Feb 14 '13 at 20:06
    
Moontear, thanks for your compliments :) we had a specific business requirement.... :) –  Sudhir Kesharwani Feb 19 '13 at 20:27

1 Answer 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.

share|improve this answer
    
How do I specify if I need to audit only a specific group and not all the security group –  Sudhir Kesharwani Feb 19 '13 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 Feb 20 '13 at 9:15

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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