且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

帮助IIS上的Windows身份验证用户登录

更新时间:2022-10-23 10:59:50

http,


范围,

rootScope,

I got assigned to fix a problem left by another developer who just changed jobs, and I'm not having very much luck with it.

The application is a time entry site that allows users to log in with their existing Windows credentials to manage their time. I can pass their username and password in JSON via Postman to the login page and it will authenticate, however, when the same credentials are entered into the form via browser, it fails.

I've posted some screenshots and code behind the login page below. If there's anything else you need to see, just let me know.

http://delorean.cisng888.csa/

Album hosted on sli.mg[^]

(function() {
  angular.module('Thunderdome').controller('LoginController', function($http, $scope, $rootScope, $location, $cookieStore, $state, loggedInUser, Logout, RetrieveSystemStatus) {
	RetrieveSystemStatus.retrieveStatus()
		.then(function(data){
			if(data[1].Value == "0")
			{
				$rootScope.systemStatus = data[1].Value;
				$rootScope.systemMessage = "";
				executeController()
			}
			else if(data[1].Value == "-1")
			{
			
				$rootScope.systemMessage = data[0].Value;
				$scope.message = $rootScope.systemMessage;
				$rootScope.systemStatus = data[1].Value;
			}
			else
			{
				$rootScope.systemMessage = data[0].Value;
				$scope.message = $rootScope.systemMessage;
				$rootScope.systemStatus = data[1].Value;
				executeController();
			}				
		},
		function(error){
		});
		
	function executeController()
	{
		//////////////////////////////////////////////////////////////////////////////
		//Initial Information
		$scope.message = ($rootScope.systemMessage == "" ? "Welcome to Time Entry." : $rootScope.systemMessage);
		$scope.username = "";
		$scope.password = "";
		$scope.returnedData = {};
		$scope.userAlreadyLoggedIn = false;
		$scope.showModal = false;
		
		if(!loggedInUser.getProfile().init)
		{
			if(!loggedInUser.getProfile().errors.length)
			{
				$state.go('home.main');
			}
			else
			{
				$scope.message = loggedInUser.getProfile().errors[0].message;
			}
		}
		/////////////////////////////////////////////////////////////////////////////////
		//Function: login()
		//Upon the user submisssion, perform the service call to build the user/employee's information for usage throughout the application.
		$scope.login = function()
		{
			var data = {
							"userName": $scope.username,
							"password": $scope.password,
							"browserString": navigator.appName
					}
			$http({
				  method: 'post',
				  url: 'http://10.1.150.174:8002/TimeEntry.svc/Login', 
				  headers: {'Content-Type':'application/json; charset=UTF-8; charset-uf8'},
				  data: data
				})
			.success(function(data, status, headers, config) {
				$scope.returnedData = data;
				evaluateSuccessfulRetrieval();
			})
			.error(function(data, status, headers, config) {
				$scope.message = "Oops, there has been issue.";
			});
				
		}
		
		/////////////////////////////////////////////////////////////////////////////////
		//Function: evaluateSuccessfulRetrieval(data)
		//Takes the information and evaluates for any errors that may have been returned.
		function evaluateSuccessfulRetrieval()
		{
			
			if($scope.returnedData.errors.length > 0)
				handleReturnedError($scope.returnedData.errors);
			else
			{
				$cookieStore.put("FunStuff", $scope.returnedData.auth);
				loggedInUser.setProfile($scope.returnedData);
				$state.go('home.main');
			}
			
		}
		
		/////////////////////////////////////////////////////////////////////////////////
		//Function: handleReturnedError(errors)
		//Handle any returned errors from the service call.
		function handleReturnedError(errors)
		{
			if(errors[0].code != 2)
				$scope.message = errors[0].message;
			else
				handleUserAlreadyLoggedIn();
		}
		
		/////////////////////////////////////////////////////////////////////////////////
		//Function: handleUserAlreadyLoggedIn()
		//Display the modal and remove the ability of the user to access the form elements.
		function handleUserAlreadyLoggedIn()
		{
			$scope.userAlreadyLoggedIn = true;
			$scope.showModal = true;
		}
		
		/////////////////////////////////////////////////////////////////////////////////
		//Function: handleUserAlreadyLoggedIn()
		//Handles the exception when a user is logged in elsewhere ro their session is still active.
		$scope.logout = function(code)
		{
			$scope.showModal = false;
			
			if(code == '2')
				logOutOtherLocation();
			else
				$scope.userAlreadyLoggedIn = false;
		}
		
		/////////////////////////////////////////////////////////////////////////////////
		//Function: logOutOtherLocation()
		//Log out the user's other session and proceed to log in this session.
		function logOutOtherLocation()
		{
			var logoutdata = {
							"Auth": "",
							"EmployeeID": $scope.username,
							"LogoutType": "2"
							}
			
			Logout.logout(logoutdata)
			.then(function(data){
				$scope.login();
			},
			function(error){
				$scope.message = "Oops, there has been issue.";
				$scope.userAlreadyLoggedIn = false;
			});
		}
	}
	
	
    });
}());



What I have tried:

Checked the code and tinkered with setting in IIS manager

http,


scope,


rootScope,