Skip to main content
Visual C++ Samples 
ConfirmUser 

Demonstrates how to register a user with a Web site and confirm the validity of the user's e-mail address.

  • IIS

  • SQL Server

  1. Create a SQL server database and run the Signup.sql SQL script to create the necessary tables and stored procedures.

  2. Before building and deploying the application, double-click ConfirmUser.udl and configure the data link properties to point to the database you just set up.

    If the database connection uses Windows authentication, make sure that the IUSR_Machine account has read-write access to the database. See ATL Server Security for information about the accounts used by a typical ATL Server application running in IIS.

    If the database connection uses SQL authentication, make sure that the security information is persisted.

  3. Configure an SMTP server and edit the code in ConfirmUser.cpp to use that server.

    NoteNote

    A warning advising you to change the server name will appear during the compilation and will guide you to the code that needs changing.

  4. After building and deploying the application, change the NTFS security settings on the UDL file that was deployed to the same location as ConfirmUser.dll to allow read access by the IUSR_Machine account.

Use a browser to view ConfirmUser.srf. Choose a user name and password, and enter a valid e-mail address. If your user name is not available, you will have a chance to enter another. If your user name is available, the Web application will send you an e-mail message asking you to visit a unique Web page and enter your user name and password. By visiting the page and entering your name and password, the application can be sure that your e-mail address is valid and that you remember your user name and password.

The server looks up the user name that you enter to confirm that it is not already taken. If it is free, your details are added to the database and marked as unconfirmed. The application generates a random GUID at this time and stores that in the database along with the other details.

The application generates a message and sends e-mail to the address provided using the CMimeMessage and CSMTPConnection classes. The e-mail contains a URL that includes the GUID generated for you. When you navigate to that URL, the application generates a login page that allows you to enter your user name and password and also adds the GUID to a hidden form field.

When the page is posted back to the server, if the user name, password, and GUID all match an unconfirmed user in the database, that user is marked as confirmed.

Demonstrates