I invite external users to a site collection named "Extranet" in my Office365 tenant and needs to give them access to a list in another site collection so I'm doing a timer job for that.
My problem is that when the users accepts the invite they are added to the extranets allusers list but not to the other site collection so the users are not available to add in a Group in the other site collection.
I'm trying to add the new user to the site collection with the Web .EnsureUser but It cannot find user.
I'm using client side code in a Console Application so there are no SPnnnnn objects available
This is my code:
var web = extranetContext.Web; User tempuser = web.SiteUsers.GetByEmail(mailToAddToGroup); extranetContext.Load(tempuser); extranetContext.ExecuteQueryRetry(); clientContext.Web.EnsureUser(tempuser.LoginName); clientContext.ExecuteQueryRetry();
What am I missing?