locked
service accounts RRS feed

  • Question

  • Hi all,

    Our CIO left and I want to remove him from SharePoint.  Is there a way to see if his user account is associated with anything that may break?

    Example, he was secondary site Admin, I removed him from the role and placed myself in. 

    He created many sites, will removing him have any effect?

    All the services that I see are all using a Domain user, so that should be OK.

    TIA,

    Joe

     

     

     

    • Moved by Mike Walsh FIN Thursday, September 1, 2011 9:15 AM admin q (From:SharePoint - Design and Customization (pre-SharePoint 2010))
    Wednesday, August 31, 2011 8:05 PM

Answers

  • Hi,

    Here you go:

    using System;

    using System.Collections.Generic;

    using System.Linq;

    using System.Text;

    using Microsoft.SharePoint;

    using Microsoft.SharePoint.Administration;

     

    namespace UserPermissionCheck

    {

        class Program

        {

            static void Main(string[] args)

            {

                SPFarm farm = SPFarm.Local;

                String name = "Login name of your CIO"; //Add login name of your CIO here

                SPWebService webService = farm.Services.GetValue<SPWebService>("");

                foreach (SPWebApplication webApplication in webService.WebApplications)

                {

                    foreach (SPSite site in webApplication.Sites)

                    {

     

                        foreach (SPWeb web in site.AllWebs)

                        {

                            SPUserCollection users = web.Users;

     

                            foreach (SPUser user in users)

                            {

                                if (user.LoginName.Equals(name))

                                {

                                    int group = 0;

     

                                    foreach (SPGroup spgroup in web.Groups)

                                    {

                                        foreach (SPUser groupuser in spgroup.Users)

                                        {

                                            if (groupuser.LoginName.Equals(name))

                                            {

                                                Console.WriteLine("The group " + spgroup.Name + " contains the user " + groupuser.LoginName + " at this site " + web.Title + "\n");

                                                group = 1;

                                                break;

                                            }

                                        }

                                    }

                                    if (group.Equals(0))

                                    {

                                        Console.WriteLine("The user " + name + " is directly added in the site " + web.Title);

                                    }

     

                                }

     

                            }

     

                        }

                    }

                }

                Console.ReadLine();

                }

        }

    }

     You just need to provide login name and nothing else.
    I hope this will help you out.


    Thanks, Rahul Rashu
    • Marked as answer by Jaylou Friday, September 2, 2011 12:20 PM
    Friday, September 2, 2011 2:55 AM

All replies

  • Hi,

    I do not think so is there any in built tool to check this.

    However with object model it is very easy to achive

    Let me know if you need code for this.

     


    Thanks, Rahul Rashu
    Thursday, September 1, 2011 2:09 AM
  • Any help would be grreatly appreciated :)

    Thanks

    Thursday, September 1, 2011 12:13 PM
  • > Any help would be grreatly appreciated :)

    This looks suspiciously like a (far too early) bump.

    If you want some code from Rahul Rashu, say just that. That was what he was offering.

     

    Moderator


    SP 2010 "FAQ" (mainly useful links): http://wssv4faq.mindsharp.com/default.aspx
    WSS3/MOSS FAQ (FAQ and Links) http://wssv3faq.mindsharp.com/default.aspx
    Both also have links to extensive book lists and to (free) on-line chapters
    Thursday, September 1, 2011 12:50 PM
  • In  my mind that is what I said. 

     

     

    Thursday, September 1, 2011 1:05 PM
  • Hi,

    Here you go:

    using System;

    using System.Collections.Generic;

    using System.Linq;

    using System.Text;

    using Microsoft.SharePoint;

    using Microsoft.SharePoint.Administration;

     

    namespace UserPermissionCheck

    {

        class Program

        {

            static void Main(string[] args)

            {

                SPFarm farm = SPFarm.Local;

                String name = "Login name of your CIO"; //Add login name of your CIO here

                SPWebService webService = farm.Services.GetValue<SPWebService>("");

                foreach (SPWebApplication webApplication in webService.WebApplications)

                {

                    foreach (SPSite site in webApplication.Sites)

                    {

     

                        foreach (SPWeb web in site.AllWebs)

                        {

                            SPUserCollection users = web.Users;

     

                            foreach (SPUser user in users)

                            {

                                if (user.LoginName.Equals(name))

                                {

                                    int group = 0;

     

                                    foreach (SPGroup spgroup in web.Groups)

                                    {

                                        foreach (SPUser groupuser in spgroup.Users)

                                        {

                                            if (groupuser.LoginName.Equals(name))

                                            {

                                                Console.WriteLine("The group " + spgroup.Name + " contains the user " + groupuser.LoginName + " at this site " + web.Title + "\n");

                                                group = 1;

                                                break;

                                            }

                                        }

                                    }

                                    if (group.Equals(0))

                                    {

                                        Console.WriteLine("The user " + name + " is directly added in the site " + web.Title);

                                    }

     

                                }

     

                            }

     

                        }

                    }

                }

                Console.ReadLine();

                }

        }

    }

     You just need to provide login name and nothing else.
    I hope this will help you out.


    Thanks, Rahul Rashu
    • Marked as answer by Jaylou Friday, September 2, 2011 12:20 PM
    Friday, September 2, 2011 2:55 AM
  • thank you !!
    Friday, September 2, 2011 12:20 PM