1. Procedures
Here's how to enable Windows authentication step by step.
1. At the menu click Edit > Tags > Objects and include 4 (four) new tags, as shown in table 1.
Name |
Type |
ID User |
Text |
Domain |
Text |
ListUser |
Text |
GetloggedinUserName |
Text |
Table 1: Tags to be added.
2. At the same Edit menu, access Scripts > Classes and create a new class, as shown in table 2.
Name |
Code |
Domain |
Windows autentication |
CSharp |
Server |
Table 2: Class to be added.
3. After creating this class, double-click it, and the CodeBehind tab, which has a text editor, will open. Add the following text:
// Windows autentication
[ System . Runtime . InteropServices . DllImport (" advapi32 .dll") ]
public static extern bool LogonUser ( string userName , string
domainName , string password , int LogonType , int LogonProvider , ref
IntPtr phToken ) ;
public string GetloggedinUserName ()
{
System . Security . Principal . WindowsIdentity currentUser =
System . Security . Principal . WindowsIdentity . GetCurrent () ;
return currentUser . Name ;
}
public bool IsValidateCredentials ( string userName , string password ,
string domain )
{
IntPtr tokenHandler = IntPtr . Zero ;
bool isValid = LogonUser ( userName , domain , password , 2 , 0 , ref
tokenHandler ) ;
return isValid ;
}
4. Continuing with Scripts, go to the Tasks tab. Browse to the ClientStartup task and double-click it. The CodeBehind tab opens. Replace all existing code with the code in the file TaskClientStartup.txt.
5. Finally, in the Edit menu, go to Security and, for all users created by the client, change the password to wa.
Note: If the "Password" field is not visible, right click on the first line, which is written Name; Permissions; Policy ..., and enable the "Password" field.
2. Results
If the operation succeeds, the user will see the message in Figure 1. Otherwise, the message seen will be as shown in figure 2. If this happens, redo the steps described in the Procedures section and try again.
Figure 1: Message seen by the user if the changes were successful (User successfully logged in).
Figure 2: Message seen by the user in case of an error in the process (User does not have permission and will be logged in as Guest).