sharepoint - Using ASP.NET Role Provider from Non Web Application (Timer Job) to check Role Membership -
i using code in sharepoint web part, checks if user in role (for forms based authenticated sites).
foreach (string role in system.web.security.roles.getallroles()) foreach (string user in system.web.security.roles.getusersinrole(role))
i compare usernames existing users in role, , username (as string) trying authorize. , works fine, expected, long role provider setup web application.
however, have timer job used process incoming emails sent smtp server , relayed locally smtp drop folder (c:\inetpub\mailroot\drop
). timer job reads email drop folder, , parses/processes it. identity user sending email, take "from address" , lookup sharepoint site user's identity using sputility.
but, need check if user in role specified web site's fba role provider. role provider details black box, unknown , can changed @ run time, have use role provider built-in functionality, ie. roles.getallroles
, roles.getusersinrole(x)
. (i can't go directly database or other behind scenes data source). know address of website need authorize user against job timer.
but, system.web.security.roles.getallroles()
not accessible job timer because not asp.net web application (actually part of owstimer.exe windows service).
so, how check if "loginname" member of role within job timer?
note: question asked leaving sharepoint out, , assuming want check "loginname" within windows service or winforms application. need check if user in fba role (roleprovider specified in asp.net 2.0-3.5 web application's web.config settings), source not windows application role provider defined , accessible.
also, can't use web service since goal have sharepoint web part , sharepoint job timer.
you're not specifying sharepoint version, i'll assume you're talking sharepoint 2007 here. however, same principle apply sharepoint 2010.
the owstimer.exe file stored in 12hive\bin. can create owstimer.exe.config file in same folder , register role , membership providers in file same way in web.config file.
for example, take @ article http://msdn.microsoft.com/en-us/library/bb977430(v=office.12).aspx (the interesting part in topic 'alerts')
Comments
Post a Comment