The below script is a modification of the Microsoft script found here: https://technet.microsoft.com/en-us/library/dn636121(v=ws.11).aspx. I have added some extra feature missing from the original as well as the ability for default login domain to work in the change password dialog as well. The script below will give you the following benefits:
- The ability to set a default domain for ADFS both on the login page and in the change password page.
- Other users can still specify a domain or a UPN in which case the script will not append the domain to the front
- Works on any Java enabled browser
You only need to change the “MYDOMAIN” in the two places below and that’s it the script is ready. Then just add it to the end of onload.js, you can use the instructional on https://technet.microsoft.com/en-us/library/dn636121(v=ws.11).aspx for instructions on how to load it.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
if (typeof Login != 'undefined'){
Login.submitLoginRequest = function () {
var u = new InputUtil();
var e = new LoginErrors();
var userName = document.getElementById(Login.userNameInput);
var password = document.getElementById(Login.passwordInput);
if (userName.value && !userName.value.match('[@\\\\]'))
{
var userNameValue = 'MYDOMAIN\\' + userName.value;
document.forms['loginForm'].UserName.value = userNameValue;
}
if (!userName.value) {
u.setError(userName, e.userNameFormatError);
return false;
}
if (!password.value)
{
u.setError(password, e.passwordEmpty);
return false;
}
if (password.value.length > maxPasswordLength) {
u.setError(password, e.passwordTooLong);
return false;
}
document.forms['loginForm'].submit();
return false;
};
}
if (typeof UpdatePassword != 'undefined'){
UpdatePassword.submitPasswordChange = function () {
var u = new InputUtil();
var e = new UpdErrors();
var userName = document.getElementById(UpdatePassword.userNameInput);
var oldPassword = document.getElementById(UpdatePassword.oldPasswordInput);
var newPassword = document.getElementById(UpdatePassword.newPasswordInput);
var confirmNewPassword = document.getElementById(UpdatePassword.confirmNewPasswordInput);
if (!userName.value || !userName.value.match('[@\\\\]')) {
var userNameValue = 'MYDOMAIN\\' + userName.value;
document.forms['updatePasswordForm'].UserName.value = userNameValue;
}
if (!oldPassword.value) {
u.setError(oldPassword, e.oldPasswordEmpty);
return false;
}
if (oldPassword.value.length > maxPasswordLength) {
u.setError(oldPassword, e.oldPasswordTooLong);
return false;
}
if (!newPassword.value) {
u.setError(newPassword, e.newPasswordEmpty);
return false;
}
if (newPassword.value.length > maxPasswordLength) {
u.setError(newPassword, e.newPasswordTooLong);
return false;
}
if (!confirmNewPassword.value) {
u.setError(confirmNewPassword, e.confirmNewPasswordEmpty);
return false;
}
if (newPassword.value !== confirmNewPassword.value) {
u.setError(confirmNewPassword, e.mismatchError);
return false;
}
var error = document.getElementById('error');
error.innerHTML = '';
return true;
};
}
|