Subscribe
E-mail
Download View Codeplex Project Site
Powered by: newtelligence dasBlog 1.9.7174.0
Disclaimer The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.
© Copyright 2008, Rich Finn
dasBlog MOSS template
My friend Mark is working on a MOSS project where all authenticated users have access to the web application, but because they might not have browsed the site yet, he wasn't able to get an SPUser object for them because they weren't yet in the content database.
I'm big fan of the Contact object in the Microsoft.Office.Workflow.Tasks.dll, so we started down the path using this object, and figured out the code to make it happen:
Contact contact = Contact.FromName("domain\\name", SPContext.Current.Web); if (contact.PrincipalID < 0) { SPContext.Current.Web.AllowUnsafeUpdates = true; SPPrincipal p = contact.GetPrincipal(SPContext.Current.Web); } SPUser newUser = SPContext.Current.Web.SiteUsers[contact.LoginName];
Here's how I know it works:Before this came up, I hadn't granted 'all authenticated users' access to my dev site yet. To test the code, I gave all authenticated users access as readers to the root web of the site, added a new user to my domain, then ran the code looking for the new user's user name.
You might run into security issues with this code in your running app because of SPContext, but you can always elevate privileges if you need to.
I found that the user is added to the 'People and Groups: All People' list. This should be interesting in large population situations. If anybody has any thoughts, please let me know...