Page History
Now you have completed your ExternalWindowsUserServices reusable part, it's time to test it.
Create a server module called TestWindowsUserServicesModule and add the following code to the server module:
* Fields
...
Define Field(#Fld_Domain) Type(*NVARCHAR) Length(200)
...
Define Field(#Fld_UserName) Type(*NVARCHAR) Length(200)
...
Define Field(#Fld_Password) Type(*NVARCHAR) Length(1000)
* Server routine
...
Srvroutine Name(TestAuthenticateUser)
...
Field_Map For(*INPUT) Field(#Fld_Domain) Parameter_Name(Domain)
...
Field_Map For(*INPUT) Field(#Fld_UserName) Parameter_Name(UserName)
...
Field_Map For(*INPUT) Field(#Fld_Password) Parameter_Name(Password)
...
Field_Map For(*OUTPUT) Field(#Fld_Message) Parameter_Name(Message)
...
* Create an instance of the ExternalWindowsUserServices reusable part
...
Define_Com Class(#ExternalWindowsUserServices) Name(#Services)
...
* Create an instance of the invocation status object
...
Define_Com Class(#ExternalServiceInvocationStatus) Name(#Status)
...
* Invoke the 'Authenticate' method
...
#Services.Authenticate Domain(#Fld_Domain) Username(#Fld_UserName) Password(#Fld_Password) Invocationstatus(#Status)
...
* If not OK, get the error message
...
If (*Not #Status.OK)
...
#Fld_Message := #Status.ErrorMessage
...
Endif
...
Endroutine
Create a webpage to invoke your server module:
...
Evtroutine Handling(#Com_owner.Initialize)
...
Define_Com Class(#TestWindowsUserServicesModule.TestAuthenticateUser) Name(#Authenticate)
...
Define_Com Class(#PRIM_DC.UnicodeString) Name(#Message)
...
* Invoke the copy service via the server routine
...
* Adjust the source & target file paths
...
#Authenticate.Execute Domain('MyDomain') UserName('MyUserName') Password('MyPassword') Message(#Message)
...
* Check if the server routine returns any error message
...
If (#Message.CurChars > 0)
...
#SYS_WEB.Alert( #Message )
...
Else
...
#SYS_WEB.Alert( 'All good!' )
...
Endif
...
Endroutine