Hello All:
How to create a sharepoint 2007 site by impersonating with custom account, so that it wont show login prompt box
Hello All:
How to create a sharepoint 2007 site by impersonating with custom account, so that it wont show login prompt box
Use SPSite constructor where you pass SPUserToken object To get token of some user, use SPWeb.AllUsers["userLoginName"].UserToken
I think that to be able get a user token you should be running your code with elevated priviledges and that might be why is pompting for login (beacuse the anonimous user doesnt have permissions to get another users token)
Example
SPSecurity.RunWithElevatedPrivileges(delegate()
{
//is important that you instantiate your SPSite object within you elevated code
using (SPSite oSite = new SPSite("your site URL"))
{
using (SPWeb oWeb = "your web")
{
//your code to run elevated
}
}
});