How to add external user to the group programmatically in SharePoint?

Hi all,
I want add an external user to a sharepoint group:
When I run the below code in ConsoleApplication the user will be added to the DemoGroup,
but when I add my code to User Control and run the code on SharePoint it doesnt work and I get an error:
The user does not exist or is not unique.<nativehr>0x81020054</nativehr><nativestack></nativestack>
Now I change the code:
SPUser user = spWeb.EnsureUser(userName);
I get again an error:
The Specified user i:0#.f|IT2S|Doe, John was not found.
string extName = "Doe, John";
string domainName = System.Environment.UserDomainName;
// in sp this is way how we get the domain:
//string domainName = System.Environment.GetEnvironmentVariables()["USERDOMAIN"].ToString();
web.AllowUnsafeUpdates = true;
string userName = string.Format("i:0#.f|{0}|{1}", domainName, extName);
web.SiteUsers.Add(userName,"[email protected]", extName, "0222");
SPUser user = web.SiteUsers[userName];
if (user != null)
web.Groups["DemoGroup"].AddUser(user);
web.Update();
web.AllowUnsafeUpdates = false;
can anyone please help me and say why that not work? Or if someone have an idea?
thank you in advance
Ahmad
SP 2013 & SPD 2013 & VS 2013 & MSSQL 2012

Hi Linda Li,
yes I solve the issue with FBA:
http://chrisbarba.com/2013/07/16/sharepoint-2013-forms-based-authentication-fba/
and
http://sharepointsolutions.blogspot.de/2012/08/configuring-forms-based-authentication.html
with above links I solved the task.
Best Regards
Ahmad
SP 2013 & SPD 2013 & VS 2013 & MSSQL 2012

Similar Messages

  • How to add a user to the wheel group?

    How to add a user to the wheel group in leopard?

    In Leopard, users can be added to system groups using 'dscl'. For example, while logged into an "admin" account, the command below can be entered using "/Applications" > "Utilities" > "Terminal.app" to add a user "username" to the "wheel" group:<pre>
    sudo /usr/bin/dscl . -append /groups/wheel GroupMembership username</pre>
    If you prefer a GUI, "Workgroup Manager.app", included with the Leopard version of the "Server Admin Tools" can be used.
    http://www.apple.com/support/downloads/serveradmintools105.html

  • Regarding : How to add a user to portal group with the help of webdynpro .

    Hii ,
    I am working on an application in which with the help of an action( Button)  we r adding a user in Ztable in R/3 , as well as  group in portal.
    The user r successfully creating in Ztable but from portal side No user is assigned to Portal group.
    I need coding solution for " How to add a user to portal group with help of webdynpro"
    Any usefull link will also do.
    Pls anyone have any solution ??
    Thnks in advance.
    Rewards r waiting for u .

    Hi,
    Use UME api to add user to portal group.
    Using UME API:
    https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/40d562b7-1405-2a10-dfa3-b03148a9bd19
    Regards,
    Naga

  • How to Add multiple entry to the group policy security filtering

    How to Add multiple entry to the group policy security filtering
    Is there any way we can add multiple entry to the Domain group policy Security filtering tab.Currently its not allowing to add more then one entry at a time.
    Getting Error like "only one name can be entered,and the name cannot contain a semicolon.Enter a valid name"

    Hi
    Are you trying to add more users or groups through Group Policy Management Security Filtering tab?
    Try right clicking on the policy and then edit
    Then in Editor Right click on the name of the policy and Properties
    Security tab and add user or group from this tab. Just make sure if you are adding user or groups "Select this object type" has
    the correct option also "From this Location" is set to your entire directory not the local server.
    Update us with the above.
    Thanks

  • How to add a button to the grouped data in an AdvancedDataGrid?

    Hi,
    Can anyone please suggest how to add a button to the grouped data in the AdvancedDataGrid?
    I have tried extending the AdvancedDataGridGroupItemRenderer and using it as the groupItemRenderer but its not reflecting.
    For the leaf node the itemRenderer property works just fine.
    Please help!

    HI ,
    I want to add a push button on the ALV list out put which is comming as a pop up and I want this using classes and methods.
    I have got a method IF_SREL_BROWSER_COMMANDS~ADD_BUTTONS from class cl_gos_attachment_list  but still I am unable to get any additional button on the output ALV popup.
    Please help.
    Regards,
    Kavya.

  • How to add external users?

    Hi, I have a sharepoint 2013 site and I got the users from an active directory, now I have to add external users but I can't add these to the active directory, how can I do it? I have imagined two ways:
    1. create a local active directory in my machine, add users and import them from central administration (I don't know if this is possible)
    2. add form web authentication and create the users in it.
    there is any other way? what do you recommend?
    luis molina

    Hi Luis Molina,
    Second option is the correct approach to address your concern,
    You can find the ready solution here
    SharePoint 2013 FBA - Configuration
    If you want to implement on your own, please follow this document provided my MS.
    SharePoint
    2013 FBA - Configuration Resource Document
    Murugesa Pandian., SharePoint 2010 | MCPD | MCTS -Configure

  • How to add BPC users in the batch?

    I would like to add BPC users in the batch.
    Does anyone know how to achieve this on BPC 7.0 MS?
    I think it is almost impossible to add thousand of BPC users without errors via BPC Admin Console.

    Hi,
    The solution proposed by Sakthi will work if you want to give to all this account the same level of security.
    Once you're in the "Add User", the AD filter will show all accounts. Just select all of them and choose team / task profile .. etc in next screens.
    Maybe you could create seperate domain group like BPC Admins, BPC Users.. and so on. And create customized filter for each of them. So when you add your users, just select the right AD filter and give to them the right set of security parameters.
    Edited by: Sebastien Michel on Jun 19, 2009 3:01 PM

  • How to add external user in sharepoint using infopath web part

    hi,
    what i am trying to achieve is,
    1. Create an infopath web part which will take email id of external user as input(ex: [email protected]).
    2. Take an email id of that user into infopath form and add that to sharepoint group.
    3. Now that newly added user must be able to login in to sharepoint using his email id.
    How could i achieve this? 
    If redirect me to example or screen shots then it will be better to understand.

    Out of the box you can not use email address and passwords to authenticate, for this you would need to create a custom authentication mechanism
    http://code.msdn.microsoft.com/office/Claims-Walkthrough-51beedc5
    or just google it:
    https://www.google.be/search?hl=en&q=sharepoint+custom+authentication+provider&btnG=Search&meta=&aq=f&aqi=g10&aql=&oq=&gs_rfai=
    Once this is implemented, you need to create custom code in you form, to call this new API and register the user, but 2nd step depends on how you do first.
    Follow me on Twitter <<<
    levalencia Blog <<<

  • How to add external jars in the configuration of JSmooth?

    Hello,
    I am trying to create an exe file from a java program using JSmooth.
    The program is a simple hello world proogram.
    I am developing under eclipse, and I am using some external jar files as libraries.
    If my program is simple,; it works fine. If I add an import of a class that is in one of these jar files, I get the following error when executing the created .exe file:
    "Could not find the main class. Program will exit".
    I guess I have to add this Jar file to the path for the creation of the .exe file.
    My question is: does anybody know HOW to add an external jar in the configuration of JSmooth for the creation of an exe file from a Java program?
    Thanks for your help
    Philippe

    i have the same problem phsans
    you know the answers??
    thanks phsans:D

  • Add external users to WAAD Tenant with Graph API

    Hello,
    is there a way to add an external user to my tenant in WAAD using Graph Api. In Azure Portal when I'm adding new user there are several options (Hotmail acc, User from existing AD) and those are the actions I'm looking for in Graph Api. Is there any way
    to do that programmatically?
    Thanks,
    Andrija

    Hi,
    I am not sure you could use Graph Api to add external user.
    The API only provides operations on objects inside the AD of your tenant.
    https://msdn.microsoft.com/en-US/library/azure/hh974476.aspx
    Regards.
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Support, contact [email protected]

  • How to add a user to an existing group????

    Can't seem to find how to add a user to an existing group (staff). I am trying to share data (rw) between my admin account (root) and a development user. On any other UNIX system I would just add the user name in the /etc/group file & logout/login in. It don't work here!
    Suggestions??
    thanx
    mt

    OS X doesn't use /etc/groups. This file is present but does nothing AFAIK.
    Leopard uses directory services to handle groups and users.
    membership in groups with GID>500 can be handled from GUI in system preferences->accounts. other groups can be handled from terminal with dscl (directory services command line). do man dscl for details.
    to add a user to a group you'd do
    sudo dscl . append /groups/groupname GroupMembership username
    However, there should be no need to do it with "staff". every user with an account on your computer is a member of staff by default.

  • How can I add a User to the transport workflow

    Hi all,
       I want to add one user to the transport workflow in BW Dev system? How can I do it, PLEASE.
    Thanks.

    Hi,
    Check this if you can reset the workflow if the configuration of old user get damaged instead of creating a new one.
    http://help.sap.com/saphelp_erp2005/helpdata/en/06/1c3737f0e64142e10000009b38f839/frameset.htm
    Please reward if it helps.

  • How to send external mails to the user

    Dears,
    How to send external mails to the user who creates the sales document (Quotation)
    Can you please suggest what modification required in the FM
    Thanks,
    pinky

    You can have a partner function like 'Created by' and use an exit to populate the User ID to this partner function(dont have the system right now but i think this can be done with standard partner detr. procedure also)
    Then, create an Output type for that Partner function with transmission medium as 'External Send'. You can use the standard SAP program to trigger the email. To send the actual email after the output is trigerred, the link connection has to be set up be BASIS but if you want to check, then goto SOST and see if the email got trigerred or not.

  • How Can I add other people to the group calling wh...

    Hi,  Could you tell me how can I do this? My laptop is broken and it's in the repair center now so I have to make a call by phone or tablet. However, everytime I have to add another person to the group calling, I have to ask other people to add him/her and it's annoying. Is it available to add people from my side? Thank you in advance.

    You can add people to the chat via the little plus button left of the chat bar. If they're already in the chat and you want to add them to the call, only the host of the call can add them. I believe they have to be contacts with the host of the call or they both have to have their settings set so that they can receive calls from non-contacts as well.

  • Add Local Users to the Local Admin Group

    I am looking either via GPO or Third Party Tool.  I would like to add 6 Users to the Local Admin Groups on all the computers running Windows 7/8.  I want to Create a Group called "OUR Local Admins" and add these 6 local users (Not domain
    Users) to this Group and then nest this Group into the Local Admin Group Built-in into Windows 8
    Thank u

    > local users (Not domain Users) to this Group and then nest this Group
    > into the Local Admin Group Built-in into Windows 8
    You cannot nest local groups.
    Greetings/Grüße,
    Martin
    Mal ein
    gutes Buch über GPOs lesen?
    Good or bad GPOs? - my blog…
    And if IT bothers me -
    coke bottle design refreshment (-:

Maybe you are looking for

  • Non PO documents parked in FV60 cannot be posted through FBV0.

    Hi, I am trying to post  a document parked through FV60 in FBV0 Tcode, but the system says that the document is already posted in that compnay code even though it is in parked condition.. I tried posting some other parked documents but the system is

  • Safari in Windows 7 open links in new tab same window...

    I have searched and seen similar topics, but no one answers. On my mac there is a terminal command that does this, but I use win 7 @ work and was hoping there was a way to accomplish the same thing. I want links to open in new tabs (just like clickin

  • Power cord EU to Canada

    Dear All, I will be moving from the Netherlands to Vancouver Canada. I owe an Apple TV which I want to take with me. Can I just buy a power cord like this one, plug it in and continue to use it? No issues with voltage difference between the Netherlan

  • How do I move my blog posts from iWeb to Wordpress?

    I want to move all my blog posts from iWeb to Wordpress. Is that possible and how?

  • How do I get Snow Leopard?

    How do I get Snow Leopard for my Mac Mini?