Go Yale CAS +. NET Client implementation SSO (4)

Source: Internet
Author: User
Tags cas management studio sql server management sql server management studio

    • Part I: Installing the configuration Tomcat
    • Part II: Installing the configuration CAS
    • Part III: Implementing the ASP. NET WebForm Client
Part IV: Implementing Database-based authentication

1. Download Microsoft JDBC Driver for SQL Server.

(1) Microsoft JDBC Driver 4.0 for SQL server:http://www.microsoft.com/zh-cn/download/details.aspx?id=11774

The website provides two kinds of format files for download, one is self-extracting EXE format file, and the other is a compressed file in tar.gz format. Choose one of the two formats to download, after decompression, you can get two jar format files: Sqljdbc.jar and Sqljdbc4.jar.

(2) Since I am using SQL Server 2012, I need to copy "Sqljdbc4.jar" to the "%tomcat_home%\webapps\cas\web-inf\lib" folder.

(3) in the second part of this series, we have mentioned downloading "Cas-server-3.5.1-release.zip" from the CAS website and extracting it. Locate "MOdules\cas-server-support-jdbc-3.5.1.jar" in the uncompressed file and copy it to "%tomcat_home%\webapps\cas\web-inf\lib" Folder.

2. Create a database for authentication

(1) Start SQL Server Management Studio, create a new database "USERSDB" and establish the table "Users" in the following fields:

(2) Enter several test data in the table:

3. Configure CAs to implement database-based authentication

(1) Start the text Editing tool as an administrator and open "%tomcat_home%\webapps\cas\web-inf\deployerconfigcontext.xml". Find the following code

<bean id= "AuthenticationManager"    class= "Org.jasig.cas.authentication.AuthenticationManagerImpl" >

(2) Insert the SQL Server JDBC data Source configuration information before the code:

<bean id= "DataSource" class= "Org.springframework.jdbc.datasource.DriverManagerDataSource" >    < Property Name= "Driverclassname" value= "Com.microsoft.sqlserver.jdbc.SQLServerDriver" ></property>    <property name= "url" value= "Jdbc:sqlserver://192.168.0.123:1433;databasename=usersdb" ></property>    <property name= "username" value= "sa" ></property>    <property name= "password" value= " YourPassword "></property></bean>

As shown in the following:

(3) Find the following configuration information:

<bean class= "Org.jasig.cas.authentication.handler.support.SimpleTestUsernamePasswordAuthenticationHandler"/ >

This configuration information uses Simpletestusernamepasswordauthenticationhandler to authenticate the user, that is, the default user name and password are the same, the authentication passes, the user name password is different, the login fails. We need to replace it with configuration information based on database validation.

First, comment out the above configuration information and insert the following configuration information below it:

<bean class= "Org.jasig.cas.adaptors.jdbc.QueryDatabaseAuthenticationHandler" >    <property name= "SQL" Value= "Select Password from Users where username=?"/>    <property name= "DataSource" ref= "DataSource"/>< /bean>

Description: If you are installing SQL Server 2012, the default TCP/IP Access protocol does not open, so SQL Server data cannot be accessed by IP address, and the workaround is to start SQL Server Configuration Manager and enable TCP/IP in it. When enabled, remember to restart the SQL Server service for the settings to take effect. :

(4) Save the changes made to "%tomcat_home%\webapps\cas\web-inf\deployerconfigcontext.xml".

(5) Restart the Tomcat service.

4. Testing database-based authentication

Run the previously debugged WebForm program from the Client (refer to: Yale CAS +. NET Client for SSO (3)), enter the username "admin", password "123", and test whether the login was successful. If everything is configured correctly, you can see the interface after the program is logged in such as:

5. Further improve the login experience

In the actual use of the process, the user may want to log in a variety of ways: User name, password, mailbox, password, mobile phone number, password, how to solve a variety of ways to log on the problem? In the following sections we will discuss in depth how to solve such problems.

Go Yale CAS +. NET Client implementation SSO (4)

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.