Create SPUserToken and use like below:
string url = SPContext.Current.Site.Url;
SPUserToken token=SPContext.Current.Site.RootWeb.EnsureUser(txtUserID.Text).UserToken;
SPSite site = new SPSite(url,token);
Hope this will solve ur prob :)
Jirka wrote:
SecurityException
30-Jan-09
Hi all
my dev machine: virtual Windows Server 2008 x64, WSS 3.0 SP1 x64,
VisualStudio 2008, VSeWSS 1.3 (CTP)
I'm trying to get my webpart to WSS, deploying is correct, webpart is in
website galery list, but if I want to import to any site, it doesn't work.
I debug this situation and got:
this.ExportMode = WebPartExportMode.All;
string url = SPContext.Current.Site.Url; // this line works
correct (got the right url)
SPSite site = new SPSite(url); // this line thows
exception
the complete exception
System.Security.SecurityException was unhandled by user code
Message="Request failed."
Source="Microsoft.SharePoint"
StackTrace:
at Microsoft.SharePoint.Administration.SPPersistedObject.ToString()
at Microsoft.SharePoint.SPSite..ctor(SPFarm farm, Uri requestUri,
Boolean contextSite, SPUserToken userToken)
at Microsoft.SharePoint.SPSite..ctor(String requestUrl)
at klienti.klienti_sql..ctor()
at T_90428866_5b97_4ebf_a295_118a24ff54b2.CreateInstance()
at System.Web.HttpRuntime.FastCreatePublicInstance(Type type)
at
System.Web.UI.WebControls.WebParts.WebPartManager.ImportWebPart(XmlReader
reader, String& errorMessage)
InnerException:
the similar exception is thown by the try to connect to MSSQL ....
I have no idea how this situation resolve ... I tryied to run WSS under
domain administrator, connecting to SQL as domain administrator, add user
account in Central Administration > Application Management > Policy for Web
Application but with no effect :( ...
Regards
JH
Previous Posts In This Thread:
On Friday, January 30, 2009 10:17 AM
Jirka wrote:
SecurityException
Hi all
my dev machine: virtual Windows Server 2008 x64, WSS 3.0 SP1 x64,
VisualStudio 2008, VSeWSS 1.3 (CTP)
I'm trying to get my webpart to WSS, deploying is correct, webpart is in
website galery list, but if I want to import to any site, it doesn't work.
I debug this situation and got:
this.ExportMode = WebPartExportMode.All;
string url = SPContext.Current.Site.Url; // this line works
correct (got the right url)
SPSite site = new SPSite(url); // this line thows
exception
the complete exception
System.Security.SecurityException was unhandled by user code
Message="Request failed."
Source="Microsoft.SharePoint"
StackTrace:
at Microsoft.SharePoint.Administration.SPPersistedObject.ToString()
at Microsoft.SharePoint.SPSite..ctor(SPFarm farm, Uri requestUri,
Boolean contextSite, SPUserToken userToken)
at Microsoft.SharePoint.SPSite..ctor(String requestUrl)
at klienti.klienti_sql..ctor()
at T_90428866_5b97_4ebf_a295_118a24ff54b2.CreateInstance()
at System.Web.HttpRuntime.FastCreatePublicInstance(Type type)
at
System.Web.UI.WebControls.WebParts.WebPartManager.ImportWebPart(XmlReader
reader, String& errorMessage)
InnerException:
the similar exception is thown by the try to connect to MSSQL ....
I have no idea how this situation resolve ... I tryied to run WSS under
domain administrator, connecting to SQL as domain administrator, add user
account in Central Administration > Application Management > Policy for Web
Application but with no effect :( ...
Regards
JH
On Thursday, October 29, 2009 7:18 AM
Satish Kumar Upadhyay wrote:
Reply
Create SPUserToken and use like below:
string url = SPContext.Current.Site.Url;
SPUserToken token=site.RootWeb.GetToken...
SPSite site = new SPSite(url,token);
Hope this will solve ur problem :)
EggHeadCafe - Software Developer Portal of Choice
Custom Binary Search in ArrayLists with IComparer
http://www.eggheadcafe.com/tutorials/aspnet/4d7ea57b-cf32-4d7d-90dd-3...