Checks users Exists in user group or not?

Hi All,
bool userExsists = SPContext.Current.Web.CurrentUser.Groups.Cast<SPGroup>().Any(g => g.Name.ToLower() == "groupname".ToLower());
Is there ay alternative for findings that user is in group or not? Is it best way to achieve this?

Hi,
To check if a user exists in user group, please use the code below:
string userName = "contoso\\admin";//your user account
string groupName = "SP Members";// your user group
using (SPSite spSite = new SPSite("http://sp")) // your site collection URL
using (SPWeb spWeb = spSite.OpenWeb())
SPUser user = spWeb.EnsureUser(userName);
if (user.Groups.Cast<SPGroup>().Any(g => g.Name.Equals(groupName)))
Console.WriteLine("User " + userName + " is a member of group " + groupName);
else
Console.WriteLine("User " + userName + " is NOT a member of group " + groupName);
Or you can use PowerShell command below:
$w = get-spweb http://my
$gs = $w.SiteGroups
$g = $gs[12]
$user = $g.Users.GetByEmail("[email protected]")
if($user -eq $null){write-host "User Not Found"}
Best regards.
Thanks
Victoria Xia
TechNet Community Support

Similar Messages

  • User Group is not receiving email Sharepoint 2013 & Nintex workflow

    Hi I created circular workflow using nintex and sharepoint 2013 , now problem occur that User group did not receive email notification through web portal , sending individual email address working fine but user group is not receiving
    any email, not a single group is working now , to clear we used same workflow since last two years and all group received email earlier but now we are facing this issue since last 3 weeks. to resolve this we create new test groups and test but enable
    to send.
    looking for support to resolve this issue
    Regards

    This actually sounds like a problem that should be discussed on the Nintex forums, can you try over there?
    Kind regards,
    Margriet Bruggeman
    Lois & Clark IT Services
    web site: http://www.loisandclark.eu
    blog: http://www.sharepointdragons.com

  • User group [$CLASS] not an Org level field in IA, whereas it is in DA

    Hi All,
    We have an authorization problem that we faced while SAP Upgrade. In the development system while we upgraded all the roles, we did not face any issue. User group field [$CLASS] was actually an org level field in that system and the roles were upgraded based on that condition.
    When the Integration system was up and the upgraded roles were transported to IA, we noticed that they ended with a warning. On checking the logs we found out that User group [CLASS] actually was not an Org level value in the INtegration system, whereas it was an org level field in the development system.
    Can someone tell me the reason why it is different? Is there any settings we have to change to make User group  an org level field in IA. Thanks a lot for your help.
    Vijith

    Hello, I ran into this also and found these notes to explain why this is suddenly an org value and how to fix it:
    http://search.sap.com/notes?id=0001580048
    http://search.sap.com/notes?id=0001739055
    Basically, GRC 10 add-on makes the user group an org value and the note instructs how to undo this manually, but there is a required pre-requisite because you cannot modify this for SAP delivered fields normally.
    You know what else would be nice.... maybe there's a note that explains why Account Type is an org value.  It REALLY should not be, IMO.

  • AD users/groups are "Not Found"

    Have some issues with our Mac OS X Server (10.5.6).
    I completed the initial setup of the "golden triangle" just fine--and our Open Directory is completely integrated into our Active Directory.
    I logged in today into the server today only to find that all of the AD users and groups are listed as "Not Found" in Workgroup manager. Active Directory authentication still works but the server can't seem to pull names from AD anymore. I checked the AD directory though Workgroup manager and it didn't list any users.
    However, when I logged in to the Replica and attempted the same steps, the AD users and groups were listed, just like nothing happened. Logged back into the Master and all of the AD users are still listed as "Not Found".
    I checked all of the settings and nothing has been changed since last week (and it was working last week). However when I open Directory Utility it says on both the Replica and the Master that the Local Server isn't responding.
    Thought that a restart would do the trick but the server is being heavily used at the moment. Is there a way to restart just the LDAP server without restarted the entire server? And has anyone else had this ran into this problem before?

    Got it working by clicking twice the checkbox in front of the field  "Use UME Unique with LDAP unique".
    This updated the value from uid to samaccountname (which it should have read from the config xml file allready)

  • Transformer tags and checking user group memberships

    Is the command "stringToACLGroup ('group=203;').isMember($currentuser)" in the code below, doing a Database lookup or getting it from a cached value? If this the server API or a PRC call?
    <pt:when pt:test="stringToACLGroup ('group=203;').isMember($currentuser)" xmlns:pt='http://www.plumtree.com/xmlschemas/ptui/'> Welcome corp user!<br> ... Home Office content... </pt:when>
    Thanks.
    Vanita
    Staples

    On the machine that is having this issue, run this command:
    RSOP.msc
    When the results come up, browse to this path:
    Computer Configuration->Windows Settings->Security Settings->Restricted Groups
    Do you have a listing for "Remote Desktop Users"
    I suspect what you have going on is a GPO that is applying explicit members of that group.  That would remove anyone that you specify every 15 minutes.
    - If you have found my post to be helpful, or the answer, please mark it appropriately.  Thank you.
    Chris Ream

  • Checking user exist on resource or not before creating it

    Hi Friend,
    I have requirement in which I need to check user id exist in resource or not before creating it.
    I can not testUser as it checks user in LH not in resource. I need to see if my user is existing in particular resource.
    Can some one throw some light on it?
    Thx

    Hi Mark,
    I am creating user from resource A to resource B during active sync, but when I am creating user in recource B , i will generate unique ID and will check if any other user with same ID is existing or not.
    Thx

  • Message thrown as User group not created

    Hi,
    When the User tries to access a Transaction Code which is a (Query created from table BSEG) he gets a message that User Group has not yet been created, where as the User Group has been created and can be seen.
    We checked the SU53 screen after accessing this transaction and all checks were successful.
    Please provide ur suggestions.
    Regards,
    Priya

    Just check if the query is attached is to a User Group or not .
    GOTO to SQ02 find the infoset for the query
    goto to Environment->User Group .
    Please check this and reward if useful.

  • New user creation in AE- user group not getting assigned

    Hi All,
    Here is a typical case, wherein when we create a new user with AE for the production system, the user gets created and the roles are also assigned but the user group is not getting assigned. The user group is being fetched from a table from the backend and all that is working fine. Infact in order to test the configurations we even created a new user in the production instance of AE giving the development system as the target system for user creation and in this case the user was successfully created and the user group is also assigned. The problem is arising only when the target system is production system.
    Connectors are all working fine, but we are unable to think of a reason. Can somebody help us on this?

    Hi Vani,
    If you are provisioning the user group using user defaults, check  that production system is selected in the user defaults configured. Configuration -> user defaults. You can define any user default system, but for perticuticular user defaults that is applicable define all the systems, in which you want user defaults to be provisioned.
    Kind Regards,
    Srinivasan

  • In Infopath - From User Group webservice First & Last Name are not displaying

    Hi, I am working on Internet faced Infopath Sharepoint 2010 web application.In Infopath form we used a User Group web service to retrieve the first and last names when opening the form. In Development environment its working fine (Ex:- http://sharepoint2010dev:45/)
    then we extend the webapplication with domain name in url.(Ex:http://Domainsp:80/) then the first and last names from User Groups is not working.
    Please give your suggestions to resolve this isssue.
    Any help is appreciated..!

    Hi,
    According to your post, my understanding is that the User Group web service not worked when extend the web application with a domain name in URL.
    Did you change the URL to the UserGroup web service in the Data Connection Wizard?
    As you had changed the URL, I think you should change the URL(http://<site>/_vti_bin/UserGroup.asmx), then check whether it works.
    http://blog.ianchivers.com/2011/01/using-sharepoint-usergroup-web-service.html
    Thanks & Regards,
    Jason
    Jason Guo
    TechNet Community Support

  • Users/groups not visible in WGM after migration. (UIDs lower than 500)

    I have migrated from a 10.5 to a 10.6 server.
    Some of my user & groups are not visible in the WGM. However, the user can login to the system.
    I discovered that if I check Workgroup Manager > View > Show System Records, that I can see the missing users and groups. The users and groups all of UID/GID's from 100 to 130.
    All of the affected users & groups were created many versions ago, probably Mac OS X 10.1 Server. The accounts that are visible are newer and have UID's starting in either at 501 or 1025. So it looks like overtime OS X server has changed what ID's are used for system vs. users.
    What is the proper way to solve this problem? The WGM will let me to manually change the UID/GID, but I am worried about doing this will not change file ownerships.
    Thansk!

    You are correct, the ACL and or POSIX permissions will not update if you just change the UID of the group or user account. You will need to add the new UID to the directories in question. And be sure to propagate the permissions.
    I would take one each group and user account and use it as a test case to discover how much is involved. Document what steps are needed to make the changes and then do them in bits and pieces.

  • "Domain Users" group in Active Directory does not belong to any Group Membership in LC

    Active Directory user belonging to "Domain Users" group does not belong to any Group Membership in LC, why does it not belong to "Domain Users" group?
    Any way to correct this issue, without changing group membership on AD side?
    If Active Directory user is member of "Domain Admins" or "Users" then these show same group membership in LC.
    Thanks.

    If you want to use the Domain Users group for the purpose of representing all the users then you can use the "All principals in domain xxx" group which is created by UM.
    Coming back to Domain Users group. For determining group membership in AD UM uses "member" attribute of the group object. "Domain Users" group is treated differently by AD. It is the default primary group for all the users and normally members of the primary group are not specified using the member attribute.So when we sync the data from AD "Domain Users" membership does not get completed.

  • Active Directory Groups - Domain Users Group

    Using the AD resource adpater, I am able to assign groups and remove groups, but I noticed that the Domain Users group does not appear in the list of groups the user belongs to. Looking AD the user does belong, but in IDM it does not list this group membership. Is this normal ?

    Thanks for the reply. I noticed there are quite a few issues with trying to UNC map to any share outside of the local MXE3500. I'm also seeing some issues with FTP watches on an EMC NAS, that has been FTP enabled. The problem I'm seeing now is that the watch will only work, if the watch is at the root level. If I add a file path, its accepted as valid when I save the directory watch, but looking at the fa.log its appending the last directory on twice.
    So if my watch is looking at FTP Directory Path of: lifelink
    The fa.log shows: .../lifelink/lifelink/
    the word lifelink is displayed twice, causing an error, stating: "Error checking file size delay"
    thanks,
    Dave

  • Authenticated User group

    We have following doubt regarding Authenticated User group in Windows 7
    1. When this user group is added to a Drive/folder/file automatically.
    2. As per our observation, mostly it shows in the drive in which OS is installed. On some machines it shows in other drives. How  this is added in other automatically.
    3. Another observation is, due to the presence of this group, it is possible to write a file(which is created by administrator or system) with an application which is started with Standard User token.  So do we need to add any extra permission to work
    our application(with standard user token) to read and write to the folder/file with Authenticated User group.
    4.  Is it possible that Authenticated User group will not exist in OS installed drive.
    5. Is it possible that an application with standard user cannot write to a file/folder even if Authenticated User group is present for the same.
    Thanks, Renjith V R

    Hi,
    To learn more about authenticated users group, you can refer to the related thread:
    http://social.technet.microsoft.com/Forums/windowsserver/en-US/e1a8e680-03a2-4690-a7e5-f17ad7389ecd/authenticated-users?forum=winserverDS
    Andy Altmann
    TechNet Community Support

  • Afaria User Group

    Hi
    I'm using User Groups in Afaria based in AD group.
    I have just one problem, I don't able to see devices list when I use user group?
    What can be happening?
    Regards,
    Lucas Araujo

    You're right.
    USER groups are not shown in the link window so you can't tell if a specific policy is linked to a given device/user pair. It will be but the UI doesn't show it.
    It's a pain to debug :-(
    BR
    Peter

  • Creating User Groups

    Hi All,
    How can I create User groups in Application Express 4.0.1.00.03.
    I am not able to find the link for creating User groups after logging in as found in the Help:
    1.Log in to Oracle Application Express. See "Logging In to Oracle Application Express" in Oracle Application Express Application Builder User's Guide.
    The Workspace home page appears. Note I have logged in as administrator for Internal Workspace.
    2.Click the Administration icon. - Not able to find
    The Administration page appears.
    3. From the Tasks list, click Manage User Groups. - Not able to find
    The User Groups page appears.
    Thanks & Best Regards
    Arif Khadas

    Hello Arif,
    >> Note I have logged in as administrator for Internal Workspace
    You should login to your working workspace as a developer with workspace administrator privileges. At the Application Builder home page you’ll see the Administration icon, and within it the Manage Users and Groups icon. In this module, you should select the Manage User Groups Task.
    Regards,
    Arie.
    &diams; Please remember to mark appropriate posts as correct/helpful. For the long run, it will benefit us all.
    &diams; Author of Oracle Application Express 3.2 – The Essentials and More

Maybe you are looking for

  • HP ePrint old printer e-mail address

    I had to reinstall wireless configuration to my printer and reenable HP ePrint services. That unfortunately also meant new unique printer e-mail address. I am aware that the old e-mail address is obviously locked out for security reasons for 6 months

  • IPhoto Questions

    I have several questions on iPhoto. 1. When printing photos, Is there a way to have the existing captions retained? Everything prints fine, but without the captions. 2. How do I enlarge a photo when printing? 2. When backing up the photo library, spe

  • Monitoring BI PROCESS CHAIN with Solution Manager BPMON

    Hello, I'm trying to setup the monitoring of BI process chain using the BPMON I setup the process chain monitoring using  BPmon application monitoring "BI Process Chain Monitoring" (BOBIPCMO) but than I'm not able to read the process chain names,step

  • Automatically switch Front Row display to  a second monitor

    I know that it is possible to change the "primary monitor" in the System Proferences, start Front Row, and then manually change to primary monitor back later on, but is there a way to do this automatically? Thanks

  • Output through interface

    Hey, My headphone jack crapped out so I would like to listen to my iTunes through my Firewire interface but cannot find a place in preferances to do that...is it possible?