Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(245)

Side by Side Diff: chrome/browser/ui/webui/chromeos/login/enrollment_screen_handler.cc

Issue 2622273002: Handle login and password error for the domain join (Closed)
Patch Set: Address Michael's comments Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/resources/chromeos/login/oobe_screen_oauth_enrollment.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/webui/chromeos/login/enrollment_screen_handler.h" 5 #include "chrome/browser/ui/webui/chromeos/login/enrollment_screen_handler.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "ash/common/system/chromeos/devicetype_utils.h" 9 #include "ash/common/system/chromeos/devicetype_utils.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 } 101 }
102 102
103 103
104 // Returns the enterprise domain after enrollment, or an empty string. 104 // Returns the enterprise domain after enrollment, or an empty string.
105 std::string GetEnterpriseDomain() { 105 std::string GetEnterpriseDomain() {
106 policy::BrowserPolicyConnectorChromeOS* connector = 106 policy::BrowserPolicyConnectorChromeOS* connector =
107 g_browser_process->platform_part()->browser_policy_connector_chromeos(); 107 g_browser_process->platform_part()->browser_policy_connector_chromeos();
108 return connector->GetEnterpriseDomain(); 108 return connector->GetEnterpriseDomain();
109 } 109 }
110 110
111 enum ActiveDirectoryErrorState {
112 ERROR_STATE_NONE = 0,
113 ERROR_STATE_MACHINE_NAME_INVALID = 1,
114 ERROR_STATE_MACHINE_NAME_TOO_LONG = 2,
115 ERROR_STATE_BAD_USERNAME = 3,
116 ERROR_STATE_BAD_PASSWORD = 4,
117 };
118
111 } // namespace 119 } // namespace
112 120
113 // EnrollmentScreenHandler, public ------------------------------ 121 // EnrollmentScreenHandler, public ------------------------------
114 122
115 EnrollmentScreenHandler::EnrollmentScreenHandler( 123 EnrollmentScreenHandler::EnrollmentScreenHandler(
116 const scoped_refptr<NetworkStateInformer>& network_state_informer, 124 const scoped_refptr<NetworkStateInformer>& network_state_informer,
117 NetworkErrorModel* network_error_model) 125 NetworkErrorModel* network_error_model)
118 : BaseScreenHandler(kJsScreenPath), 126 : BaseScreenHandler(kJsScreenPath),
119 controller_(NULL), 127 controller_(NULL),
120 show_on_init_(false), 128 show_on_init_(false),
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 IDS_ENTERPRISE_ENROLLMENT_ASSET_ID_LABEL); 401 IDS_ENTERPRISE_ENROLLMENT_ASSET_ID_LABEL);
394 builder->Add("oauthEnrollLocationLabel", 402 builder->Add("oauthEnrollLocationLabel",
395 IDS_ENTERPRISE_ENROLLMENT_LOCATION_LABEL); 403 IDS_ENTERPRISE_ENROLLMENT_LOCATION_LABEL);
396 builder->Add("oauthEnrollWorking", IDS_ENTERPRISE_ENROLLMENT_WORKING_MESSAGE); 404 builder->Add("oauthEnrollWorking", IDS_ENTERPRISE_ENROLLMENT_WORKING_MESSAGE);
397 // Do not use AddF for this string as it will be rendered by the JS code. 405 // Do not use AddF for this string as it will be rendered by the JS code.
398 builder->Add("oauthEnrollAbeSuccess", IDS_ENTERPRISE_ENROLLMENT_ABE_SUCCESS); 406 builder->Add("oauthEnrollAbeSuccess", IDS_ENTERPRISE_ENROLLMENT_ABE_SUCCESS);
399 builder->Add("oauthEnrollAdMachineNameInput", 407 builder->Add("oauthEnrollAdMachineNameInput",
400 IDS_AD_MACHINE_NAME_INPUT_LABEL); 408 IDS_AD_MACHINE_NAME_INPUT_LABEL);
401 builder->Add("oauthEnrollAdDomainJoinWelcomeMessage", 409 builder->Add("oauthEnrollAdDomainJoinWelcomeMessage",
402 IDS_AD_DOMAIN_JOIN_WELCOME_MESSAGE); 410 IDS_AD_DOMAIN_JOIN_WELCOME_MESSAGE);
403 builder->Add("adLoginUser", IDS_AD_LOGIN_USER); 411 builder->Add("adLoginUsername", IDS_AD_LOGIN_USER);
412 builder->Add("adLoginInvalidUsername", IDS_AD_INVALID_USERNAME);
404 builder->Add("adLoginPassword", IDS_AD_LOGIN_PASSWORD); 413 builder->Add("adLoginPassword", IDS_AD_LOGIN_PASSWORD);
414 builder->Add("adLoginInvalidPassword", IDS_AD_INVALID_PASSWORD);
415 builder->Add("adJoinErrorMachineNameInvalid", IDS_AD_MACHINENAME_INVALID);
416 builder->Add("adJoinErrorMachineNameTooLong", IDS_AD_MACHINENAME_TOO_LONG);
405 } 417 }
406 418
407 bool EnrollmentScreenHandler::IsOnEnrollmentScreen() const { 419 bool EnrollmentScreenHandler::IsOnEnrollmentScreen() const {
408 return (GetCurrentScreen() == OobeScreen::SCREEN_OOBE_ENROLLMENT); 420 return (GetCurrentScreen() == OobeScreen::SCREEN_OOBE_ENROLLMENT);
409 } 421 }
410 422
411 bool EnrollmentScreenHandler::IsEnrollmentScreenHiddenByError() const { 423 bool EnrollmentScreenHandler::IsEnrollmentScreenHiddenByError() const {
412 return (GetCurrentScreen() == OobeScreen::SCREEN_ERROR_MESSAGE && 424 return (GetCurrentScreen() == OobeScreen::SCREEN_ERROR_MESSAGE &&
413 network_error_model_->GetParentScreen() == 425 network_error_model_->GetParentScreen() ==
414 OobeScreen::SCREEN_OOBE_ENROLLMENT); 426 OobeScreen::SCREEN_OOBE_ENROLLMENT);
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
542 base::Bind(&EnrollmentScreenHandler::OnPasswordPipeReady, 554 base::Bind(&EnrollmentScreenHandler::OnPasswordPipeReady,
543 weak_ptr_factory_.GetWeakPtr(), machine_name, user_name)); 555 weak_ptr_factory_.GetWeakPtr(), machine_name, user_name));
544 } 556 }
545 557
546 void EnrollmentScreenHandler::OnPasswordPipeReady( 558 void EnrollmentScreenHandler::OnPasswordPipeReady(
547 const std::string& machine_name, 559 const std::string& machine_name,
548 const std::string& user_name, 560 const std::string& user_name,
549 base::ScopedFD password_fd) { 561 base::ScopedFD password_fd) {
550 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 562 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
551 if (!password_fd.is_valid()) { 563 if (!password_fd.is_valid()) {
552 LOG(ERROR) << "Got invalid password_fd"; 564 DLOG(ERROR) << "Got invalid password_fd";
553 return; 565 return;
554 } 566 }
555 chromeos::AuthPolicyClient* client = 567 chromeos::AuthPolicyClient* client =
556 chromeos::DBusThreadManager::Get()->GetAuthPolicyClient(); 568 chromeos::DBusThreadManager::Get()->GetAuthPolicyClient();
557 569
558 client->JoinAdDomain(machine_name, 570 client->JoinAdDomain(machine_name,
559 user_name, 571 user_name,
560 password_fd.get(), 572 password_fd.get(),
561 base::Bind(&EnrollmentScreenHandler::HandleAdDomainJoin, 573 base::Bind(&EnrollmentScreenHandler::HandleAdDomainJoin,
562 weak_ptr_factory_.GetWeakPtr(), 574 weak_ptr_factory_.GetWeakPtr(),
563 machine_name, 575 machine_name,
564 user_name)); 576 user_name));
565 } 577 }
566 578
567 void EnrollmentScreenHandler::HandleAdDomainJoin( 579 void EnrollmentScreenHandler::HandleAdDomainJoin(
568 const std::string& machine_name, 580 const std::string& machine_name,
569 const std::string& user_name, 581 const std::string& user_name,
570 authpolicy::ErrorType code) { 582 authpolicy::ErrorType code) {
571 switch (code) { 583 switch (code) {
572 case authpolicy::ERROR_NONE: 584 case authpolicy::ERROR_NONE:
573 controller_->OnAdJoined(gaia::ExtractDomainName(user_name)); 585 controller_->OnAdJoined(gaia::ExtractDomainName(user_name));
574 return; 586 return;
575 case authpolicy::ERROR_UNKNOWN: 587 case authpolicy::ERROR_UNKNOWN:
576 case authpolicy::ERROR_DBUS_FAILURE: 588 case authpolicy::ERROR_DBUS_FAILURE:
577 case authpolicy::ERROR_PARSE_UPN_FAILED:
578 case authpolicy::ERROR_BAD_USER_NAME:
579 case authpolicy::ERROR_BAD_PASSWORD:
580 case authpolicy::ERROR_PASSWORD_EXPIRED:
581 case authpolicy::ERROR_CANNOT_RESOLVE_KDC:
582 case authpolicy::ERROR_KINIT_FAILED:
583 case authpolicy::ERROR_NET_FAILED: 589 case authpolicy::ERROR_NET_FAILED:
584 case authpolicy::ERROR_SMBCLIENT_FAILED: 590 case authpolicy::ERROR_SMBCLIENT_FAILED:
585 case authpolicy::ERROR_PARSE_FAILED: 591 case authpolicy::ERROR_PARSE_FAILED:
586 case authpolicy::ERROR_PARSE_PREG_FAILED: 592 case authpolicy::ERROR_PARSE_PREG_FAILED:
587 case authpolicy::ERROR_BAD_GPOS: 593 case authpolicy::ERROR_BAD_GPOS:
588 case authpolicy::ERROR_LOCAL_IO: 594 case authpolicy::ERROR_LOCAL_IO:
595 case authpolicy::ERROR_STORE_POLICY_FAILED:
596 ShowError(IDS_AD_DOMAIN_JOIN_UNKNOWN_ERROR, true);
597 return;
598 case authpolicy::ERROR_NETWORK_PROBLEM:
599 ShowError(IDS_ENTERPRISE_ENROLLMENT_AUTH_NETWORK_ERROR, true);
600 return;
601 case authpolicy::ERROR_PARSE_UPN_FAILED:
602 case authpolicy::ERROR_BAD_USER_NAME:
603 CallJS("invalidateAd", machine_name, user_name,
604 static_cast<int>(ERROR_STATE_BAD_USERNAME));
605 return;
606 case authpolicy::ERROR_BAD_PASSWORD:
607 CallJS("invalidateAd", machine_name, user_name,
608 static_cast<int>(ERROR_STATE_BAD_PASSWORD));
609 return;
610 case authpolicy::ERROR_MACHINE_NAME_TOO_LONG:
611 CallJS("invalidateAd", machine_name, user_name,
612 static_cast<int>(ERROR_STATE_MACHINE_NAME_TOO_LONG));
613 return;
614 case authpolicy::ERROR_BAD_MACHINE_NAME:
615 CallJS("invalidateAd", machine_name, user_name,
616 static_cast<int>(ERROR_STATE_MACHINE_NAME_INVALID));
617 return;
618 case authpolicy::ERROR_JOIN_ACCESS_DENIED:
619 ShowError(IDS_AD_USER_DENIED_TO_JOIN_MACHINE, true);
620 return;
621 case authpolicy::ERROR_USER_HIT_JOIN_QUOTA:
622 ShowError(IDS_AD_USER_HIT_JOIN_QUOTA, true);
623 return;
624 case authpolicy::ERROR_PASSWORD_EXPIRED:
625 case authpolicy::ERROR_CANNOT_RESOLVE_KDC:
626 case authpolicy::ERROR_KINIT_FAILED:
589 case authpolicy::ERROR_NOT_JOINED: 627 case authpolicy::ERROR_NOT_JOINED:
590 case authpolicy::ERROR_NOT_LOGGED_IN: 628 case authpolicy::ERROR_NOT_LOGGED_IN:
591 case authpolicy::ERROR_STORE_POLICY_FAILED:
592 // TODO(rsorokin): Add passing/displaying error codes. (see
593 // crbug.com/659984)
594 CallJS("invalidateAd", machine_name, user_name);
595 return;
596 default: 629 default:
597 LOG(WARNING) << "Unhandled error code: " << code; 630 LOG(WARNING) << "Unhandled error code: " << code;
598 CallJS("invalidateAd", machine_name, user_name); 631 CallJS("invalidateAd", machine_name, user_name,
632 static_cast<int>(ERROR_STATE_NONE));
599 return; 633 return;
600 } 634 }
601 } 635 }
602 636
603 void EnrollmentScreenHandler::HandleRetry() { 637 void EnrollmentScreenHandler::HandleRetry() {
604 DCHECK(controller_); 638 DCHECK(controller_);
605 controller_->OnRetry(); 639 controller_->OnRetry();
606 } 640 }
607 641
608 void EnrollmentScreenHandler::HandleFrameLoadingCompleted() { 642 void EnrollmentScreenHandler::HandleFrameLoadingCompleted() {
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
661 695
662 ShowScreenWithData(OobeScreen::SCREEN_OOBE_ENROLLMENT, &screen_data); 696 ShowScreenWithData(OobeScreen::SCREEN_OOBE_ENROLLMENT, &screen_data);
663 if (first_show_) { 697 if (first_show_) {
664 first_show_ = false; 698 first_show_ = false;
665 UpdateStateInternal(NetworkError::ERROR_REASON_UPDATE, true); 699 UpdateStateInternal(NetworkError::ERROR_REASON_UPDATE, true);
666 } 700 }
667 histogram_helper_->OnScreenShow(); 701 histogram_helper_->OnScreenShow();
668 } 702 }
669 703
670 } // namespace chromeos 704 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/resources/chromeos/login/oobe_screen_oauth_enrollment.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698