Check specific user is Farm Administrator in Sharepoint

See there the function below, which is self descriptive, how to find specific user is Farm Admin.

Just copy and page the function and pass the account name, it will return the bool value accourdingly.

public static bool IsFarmAdmin(string loginName)
        {
            bool isFarmAdmin = false;

            SPSecurity.RunWithElevatedPrivileges(delegate()
            {
                SPGroup adminGroup = SPAdministrationWebApplication.Local.Sites[0].AllWebs[0].SiteGroups[“Farm Administrators”];

                foreach (SPUser user in adminGroup.Users)
                {
                    if (user.LoginName == loginName)
                    {
                        isFarmAdmin = true;
                        break;
                    }
                }

            });

            return isFarmAdmin;
        }

Ref:

http://social.msdn.microsoft.com/Forums/en-US/sharepointdevelopment/thread/1fa3287a-c732-4924-b75d-fec493446389

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s