Search code examples
sharepointtimersharepoint-2007timer-jobssharepoint-timer-job

SharePoint Timer Job - Exception adding aspnet_users to security groups


I have created a custom timer job in share point 2007 which gets the list of email ids from the database and has to add it to security groups in share point.

I am getting exception "user not found" when i try to verify the user using spweb.ensureuser("emailid") or even add the user to group without verifying.

I have used web.allusers.getbyemail("emailid") as well but results in the same exception.

Also created owstimer.exe.config file with connection string and provider elements but no luck.

Any ideas?


Solution

  • spweb.ensureuser accepts either 1) Login of a user (not email) 2) a Display Name of a user that corresponds to some login. SharePoint has some "storages for logins" like AD or Forms Based Authentcation provider with an underlying services or a database. This means that what you use in spweb.ensureuser must already be found among your logins. you have to add users' logins to SharePoint and the emails will be uploaded automatically. if you want to use pure emails as logins you should learn about Claims Based Authentication in SharePoint and OpenIDs. There are several products which do that (I am not advertising any of'em :) ).