locked
how to get the list of actie users in the moss website !! RRS feed

  • Question

  • Hello Everybody,

    I need to get the list of active users with access in the moss websites like following format.

    User name         User mailid       permission

    one of the project manager requested to find list of active users with user accesses in the moss website.

    he wants to modify the user permissions.

    Kindly suggest me how to get the users with permissions.

    Thanks.


    • Edited by PVR1988 Saturday, October 11, 2014 1:40 PM
    Saturday, October 11, 2014 1:30 PM

Answers

  • Hi,

    I have developed that code to retrieve the users, groups and permissions

     if (orole.Member.PrincipalType.ToString() == "SharePointGroup")
                             {
                                 lvigroup = new ListViewItem();
    
                                 lvigroup.Text = orole.Member.LoginName;
                                 // args.GroupsList.Items.Add(lvigroup);
                                 DoUpdate1(lvigroup);
    
    
                                 Group group = clientContext.Web.SiteGroups.GetById(orole.Member.Id);
    
                                 UserCollection collUser = group.Users;
                                
    
                                 clientContext.Load(collUser);
    
                                 clientContext.ExecuteQuery();
    
                                 foreach (User oUser in collUser)
                                 {
                                     lvigroup = new ListViewItem();
                                     lvigroup.Text = "";
    
                                     lvsigroup = new ListViewItem.ListViewSubItem();
                                     lvsigroup.Text = oUser.LoginName;
                                     lvigroup.SubItems.Add(lvsigroup);
    
    
                                     //args.GroupsList.Items.Add(lvigroup);
                                     DoUpdate1(lvigroup);
    
                                     // MessageBox.Show(oUser.LoginName);
                                 }
    
    
                             }
    
                             RoleDefinitionBindingCollection roleDefsbindings = null;
                             roleDefsbindings = orole.RoleDefinitionBindings;
                             clientContext.Load(roleDefsbindings);
                             clientContext.ExecuteQuery();
                             //permission level
    
                             lvsi = new ListViewItem.ListViewSubItem();
    
                             string permissionsstr = string.Empty;
                             for (int i = 0; i < roleDefsbindings.Count; i++)
                             {
                                 if (i == roleDefsbindings.Count - 1)
                                 {
                                     permissionsstr = permissionsstr += roleDefsbindings[i].Name;
                                 }
                                 else
                                 {
                                     permissionsstr = permissionsstr += roleDefsbindings[i].Name + ", ";
                                 }
                             }



    Kind Regards, John Naguib Technical Consultant/Architect MCITP, MCPD, MCTS, MCT, TOGAF 9 Foundation

    Wednesday, October 29, 2014 10:23 AM

All replies

  • Hi,

    Check those links

    http://www.sharepointdiary.com/2013/01/audit-user-permissions-in-sharepoint.html

    http://www.sharepointdiary.com/2013/07/export-sharepoint-users-and-groups-to-excel-using-powershell.html


    Kind Regards, John Naguib Technical Consultant/Architect MCITP, MCPD, MCTS, MCT, TOGAF 9 Foundation

    Saturday, October 11, 2014 4:53 PM
  • Hi,

    Out of box there is no functionality available to give you the list of all user with permission level.So here you can write a console application which will pull these three values from user profile.If you need code please let me know i'll upload here.

    Regards

    Soni K

    Saturday, October 11, 2014 9:18 PM
  • Hi Soni,

    yes i need code urgent.could you please upload the code here.

    Thanks a lot.

    Monday, October 13, 2014 4:45 AM
  • Hello John,

    Thank you for giving the information.

    This code helps a lot . but I need users permission also.

    could you please suggest me. how to get the list of users with their permission.

    Thanks.

    Monday, October 13, 2014 11:05 AM
  • Hi,

    I have developed that code to retrieve the users, groups and permissions

     if (orole.Member.PrincipalType.ToString() == "SharePointGroup")
                             {
                                 lvigroup = new ListViewItem();
    
                                 lvigroup.Text = orole.Member.LoginName;
                                 // args.GroupsList.Items.Add(lvigroup);
                                 DoUpdate1(lvigroup);
    
    
                                 Group group = clientContext.Web.SiteGroups.GetById(orole.Member.Id);
    
                                 UserCollection collUser = group.Users;
                                
    
                                 clientContext.Load(collUser);
    
                                 clientContext.ExecuteQuery();
    
                                 foreach (User oUser in collUser)
                                 {
                                     lvigroup = new ListViewItem();
                                     lvigroup.Text = "";
    
                                     lvsigroup = new ListViewItem.ListViewSubItem();
                                     lvsigroup.Text = oUser.LoginName;
                                     lvigroup.SubItems.Add(lvsigroup);
    
    
                                     //args.GroupsList.Items.Add(lvigroup);
                                     DoUpdate1(lvigroup);
    
                                     // MessageBox.Show(oUser.LoginName);
                                 }
    
    
                             }
    
                             RoleDefinitionBindingCollection roleDefsbindings = null;
                             roleDefsbindings = orole.RoleDefinitionBindings;
                             clientContext.Load(roleDefsbindings);
                             clientContext.ExecuteQuery();
                             //permission level
    
                             lvsi = new ListViewItem.ListViewSubItem();
    
                             string permissionsstr = string.Empty;
                             for (int i = 0; i < roleDefsbindings.Count; i++)
                             {
                                 if (i == roleDefsbindings.Count - 1)
                                 {
                                     permissionsstr = permissionsstr += roleDefsbindings[i].Name;
                                 }
                                 else
                                 {
                                     permissionsstr = permissionsstr += roleDefsbindings[i].Name + ", ";
                                 }
                             }



    Kind Regards, John Naguib Technical Consultant/Architect MCITP, MCPD, MCTS, MCT, TOGAF 9 Foundation

    Wednesday, October 29, 2014 10:23 AM
  • John,

    This is a nice snippet.  Might be worth writing a step by step article for the Technet Wiki.


    Steven Andrews
    SharePoint Business Analyst: LiveNation Entertainment
    Blog: baron72.wordpress.com
    Twitter: Follow @backpackerd00d
    My Wiki Articles: CodePlex Corner Series
    Please remember to mark your question as "answered" if this solves (or helps) your problem.

    Wednesday, October 29, 2014 10:27 AM
    Answerer
  • Hello Spilt,

    Below is powershell script for getting User from SP


          [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.Sharepoint")
          $rows=@()
          $webapp= [Microsoft.SharePoint.Administration.SPWebApplication]::Lookup("Web APP URL")
          
          #$webapp.Sites
          foreach($site in $webapp.Sites){
                $web=$site.RootWeb
                $groups=$web.SiteGroups
                #$group=$web.SiteGroups|?{$_.Name -eq $GroupName}
                foreach($group in $groups){
                      foreach($user in $group.Users){
                            $row=New-Object System.Object
                            $row|Add-Member -MemberType NoteProperty -Name "Site Collection" -Value  $site.Url
                            $row|Add-Member -MemberType NoteProperty -Name "Group" -Value  $GroupName
                            $row|Add-Member -MemberType NoteProperty -Name "LoginName" -Value  $user.LoginName
                            $row|Add-Member -MemberType NoteProperty -Name "DisplayName" -Value  $user.Name
                            $rows+=$row
                      }
                }
          }
          $rows|Export-Csv -NoTypeInformation -Path "C:\rahul.csv"


    Thanks and Regards Rahul Dagar

    Wednesday, October 29, 2014 10:33 AM
  • Thanks Steven, I appreciate it, indeed I was planning to share on wiki or on the gallery, I will add it to my To Do list.

    Kind Regards, John Naguib Technical Consultant/Architect MCITP, MCPD, MCTS, MCT, TOGAF 9 Foundation

    Wednesday, October 29, 2014 10:37 AM
  • Hi Steven,

    I have created a Technet gallery about that please check it

    https://gallery.technet.microsoft.com/Get-SharePoint-2010-2dd45260


    Kind Regards,

    John Naguib

    Technical Consultant/Architect

    MCITP, MCPD, MCTS, MCT, TOGAF 9 Foundation

    Please remember to mark your question as answered if this solves your problem

    Wednesday, November 12, 2014 11:09 AM