New Discovery of moss simulated Logon

Source: Internet
Author: User

Simulating logon in Moss allows you to easily use spsecurity to simulate running.ProgramThe user in the pool.

Simulated logon sets web. currentuser as the user in the running program pool.

During use, I found that:

Conclusion 1:Code

Spsite site =   Null ;
Spweb myweb =   Null ;
Spsecurity. runwithelevatedprivileges ( Delegate ()
{
Site=Spcontent. Current. Site;
Myweb=Site. openweb ();

} );

 

That is, using spcontent. Current. site or spcontent. Current. Web to specify the site or web cannot achieve the purpose of simulation.

Discovery 2: You only need to include the obtained web code in spsecurity. runwithelevatedprivileges.

 

Spsite site =   Null ;
Spweb myweb =   Null ;
Spsecurity. runwithelevatedprivileges ( Delegate ()
{
Site= NewSpsite (siteurl );
Myweb=Site. openweb ();
//You do not need to put the following operations on the list or other updates.

} );
// Put it here.
// Until the site is released, Web. currentuser will be a simulated user.

 

Here we need to pursue the principle of simulated login. spsecurity. runwithelevatedprivileges set spweb. currentuser to the account of the running program pool. If it is not a new website object, it is illegal to assign a value to spweb. currentuser.

That's why one cannot, and two can.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.