I moved this blog to other domain: https://tech.panshin.me , please update your bookmarks

Showing posts with label C#. Show all posts
Showing posts with label C#. Show all posts

Wednesday, May 1, 2013

SharePoint custom membership provider – remind me functionality


My current project is based on SharePoint site, and I manage my users in custom Database. So for the purpose I created custom membership provider and attached to the Sharepoint site. In addition to the changes, I was requested to create a custom login page.

To login to Sharepoint, after checking password and username, I use the method:
.
.
bool res = SPClaimsUtility.AuthenticateFormsUser(this.Page.Request.Url, userEmal, 
                                                 password);
.
.
However the method does not accept “remember me” flag. I opened the method by reflector and found such lines:
.
bool isPersisted = !SPSecurityTokenServiceManager.Local.UseSessionCookies;
.
.
.
SPSessionTokenWriteType local_0 = SPSessionTokenWriteType.WriteSessionCookie;
if (isPersisted)
    local_0 = SPSessionTokenWriteType.WritePersistentCookie;
fam.SetPrincipalAndWriteSessionToken(token, local_0);
.
SPSessionTokenWriteType.WriteSessionCookie

The enum says that these are temporary cookie files, which are erased when you close your browser. When you restart your browser and go back to the site that created the cookie, the website will not recognize you. You will have to log back in (if login is required) or select your preferences/themes again if the site uses these features. A new session cookie will be generated, which will store your browsing information and will be active until you leave the site and close your browser.

SPSessionTokenWriteType.WritePersistentCookie

The enum says that these cookie files stay in one of your browser’s subfolders until you delete them manually or your browser deletes them based on the duration period contained within the persistent cookie’s file. Based on the discover, the solution for “remember me” functionality is:
.
SPSecurityTokenServiceManager.Local.UseSessionCookies = !keepMeLoggedIn.Checked;
bool res = SPClaimsUtility.AuthenticateFormsUser(this.Page.Request.Url, userEmal, password);
.

The solution add “remid me” functionality to custom log in page.

Anonymous Access SharePoint Application Page

Generally when creating a page in SharePoint it inheritance from LayoutsPageBase however a public page has to inheritance from UnsecuredLayoutsPageBaseand overriding AllowAnonymousAccess property.

public partial class ForgotPassword: UnsecuredLayoutsPageBase
{
    protected override boolAllowAnonymousAccess { get{ return true; } }
 
    protected void Page_Load(objectsender, EventArgs e)
    {
    }
}

Monday, May 4, 2009

.NET Internationalization with databa...

NET Internationalization with database resource provider and custom cultures

.NET Internationalization with database resource provider and custom cultures

Database storage is a popular option for Web-application resources, for a number of reasons. You can probably guess, at some point with a site that has thousands of pages and multiple-thousand resource entries, using assembly resources might not be ideal. It will add to run-time memory usage, not to mention the increased number of assemblies loaded into the application domain. Both of these results can have a negative impact on performance for extremely large sites, making the latency of a database call worthwhile. Database resources might also provide a more flexible and manageable environment for the localization process, for reducing duplicates, for intricate caching options, and for storing possibly larger blocks of content. Lastly, allocating resources to a database makes it possible to support more complicated hierarchies of translated content, where customers or departments might have customized versions of the text that is then also localized.

PS: Articles with information about:
Hooking meta:Resource parsing in ASP.NET 2.0? by Rick Strahl
Extending the ASP.NET 2.0 Resource-Provider Model by Michèle Leroux Bustamante
.NET Internationalization: Using Custom Cultures

Wednesday, August 8, 2007

Map Grabber

I moved this post to another place: https://tech.panshin.me/opensource/map-grabber.html please update your bookmarks.

Map Grabber

Grab maps...


Prepare maps for your holidays, your walking, your bike trips, your geocaching... You
can next print them or use them with your GPS!
This utility automatically scrolls, captures, assembles and saves maps (or other window content) from a Web page to a JPG file.
This program is freeware. Written in C# .NET2.0
Project source code is licensed under a free software/open source licensing terms:
GNU General Public License, version 2.0 or later


How to use?


- Go to the desired Web site, maximize your browser window.
- Locate the desired area on the map and zoom to the desired scale.
- In order to MapGrabber automatically realize the right scrolling, you have to parameter it according to the Web site.
Press the button 1 in MapGrabber (see illustrations), next click on the left/top corner of the map. To avoid capturing the toolbar, you can define the corner just below it.
Press the button 2 in MapGrabber, next click on the right/bottom corner of the map.
- To devide output image by slises, set the steps in one part.
- If you would like to calibrate maps in time of grabbing, you can use GPS Callibration part of the MapGrabber

You can now Save the settings for future use; each Web site will have its own settings.
The main screen:


- Menu:
Settings - Load and save your current settings for future using.
Help - The link to this page and information about me.

- Map Settings:
The position of left/top and right/left bounds of map, without active elements, on the screen. You can set points by enter the coordinates or by clicking on button "Point" and dragging the  icon to he's place on the screen.

- Capture Settings:
Delay Scroll - When Map grabber moving the map in map display program (Firefox), to program take time to response for her events. So need to delay Map grabber events according to response of display program.
Delay Capture - When Map grabber the map in map display program (Firefox), to load new images take some time. So you must set the parameter according to speed image loading.
Number of X/Y Steps - How match steps to do.

- Output image settings:
Divide Image X/Y - By how match steps divide the output image. Some programs that using output maps on pocket PC, take a lot time to load big image.
Map Path - The output image folder.

- With GPS calibration - Enable GPS automatic GPS calibration of output map.

- Show/Hide points - show/hide the map settings and GPS calibration points.

- GPS Calibration:
First point X/Y - The point of place that you know her GPS coordinates. You can set points by enter the coordinates or by clicking on button "Point" and dragging the icon to her place on the screen. You can use the magnifier to put the icon exactly to place of GPS coordinates.
First point Lat/Lon - The GPS coordinates of point.


Magnifier/Status window:




Points:



Prior to start capturing, set the amount of horizontal and vertical steps you desire.
Press the button Start.


Know Bugs:

found by me and another users.
- Memory out when grabbing more than 10X10 screens.


TODO:

what in next version.
- grab large size maps
- The GPSTuner have auto map loading feature. We can use maps with different resolution, and different level of information on map. That provide option in time of zoom out or zoom in, change maps automatically. So I want to add feature - grabbing maps with some levels of zoom.


Donation


Map Grabber is free software. The author has spent a large amount of time and effort in the development and improvement of it. The continuous development of Map Grabber needs your support. The best way to support and encourage the author, so that this project can be moved forward always, is to donate for Map Grabber project. Click the button below to donate for Map Grabber via PayPal.




Download

Map Grabber may not be bundled with other software, included on CDs etc, linked to from other web sites or made available for download elsewhere. Link to this page instead.


I moved my blog to other place: Panshin.me please for downloads go to the site.

Links / Credits


Project Page on MSDN Code Gallery
Project Page on CodePlex
Project Page on CodeProject

GPS Tuner - is an off-road navigation software for Pocket PC devices. The maps of Map Grabber is collibrated for this programm.

Capturing the Screen Image in C#
Processing Global Mouse and Keyboard Hooks in C#



Disclaimer

Personal use only. Use at your own risk. No technical support given. Don't copy or distribute copyrighted media.
Screen captures will never replace a bought genuine printed map.