Authorization services

Authorization services methods are available for use once an instance of the Web WakeUp API class has been created. The two ways of using the Web WakeUp API are:

Creating a service reference

In Microsoft Visual Studio you can add a service reference to the web service URL:

http://localhost/WebWakeUp/WebServices/AuthorisationServices.asmx
On this page:

This generates a proxy class, typically with the name AuthorisationServicesSoapClient. In code, the proxy class can then be used to access the Web WakeUp Authorization API methods. For example, the following code fragment shows the GetAuthorisedMachines() method being invoked. You must call client.Close() after use.

var client = new assc.AuthorisationServicesSoapClient();
try
{
 var resultArr = client.GetAuthorisedMachines("ACME\Joe");
 //do what you want to do with the results array.
}
catch(Exception ex)
{
 //handle the error case
}
finally
{
 client.Close(); //MUST CALL THIS
}
The code must call the client.Close() method after use.

Creating a web reference

In Microsoft Visual Studio there is an advanced option of the service reference called a web reference. For Web WakeUp you can add a web reference to the web service URL:

http://host/WebServices/AuthorisationServices.asmx

This generates a proxy web service class, typically with the name AuthorisationServicesWse. In code the class can then be used to access the Web WakeUp API methods.

For example, the following code fragment shows a reference to AuthorisationServices.asmx that has been created with the name assc and the GetAuthorisedMachines() method being invoked on the new soap client that is created via the reference:

var client = new assc.AuthorisationServicesSoapClient();
String[] result = client.GetAuthorisedMachines("ACME\Joe");
finally
{
 client.Close(); //MUST CALL THIS
}

As Web WakeUp uses windows authorization, the basic HTTP binding in the application's app.config file will also need the following security settings added:

...
<security mode="TransportCredentialOnly">
    <transport clientCredentialType="Ntlm"/>
</security>
...

The following authorization services methods are available:


AddAuthorisedMachine

bool AddAuthorisedMachine(string UserName, string MachineName)

Purpose

Adds a machine to a user's authorized list of machines.

Inputs

  • UserName – the user name for an authorized user, in the format DomainName\UserName
  • MachineName – the domain name for the machine to be added, in the format DomainName\MachineName

Returns

  • Boolean – success or failure

Example

C#
var client = new assc.AuthorisationServicesSoapClient();
try
{
 var result = client.AddAuthorisedMachine("ACME\Joe",
                                          "ACME\ACMEdvwks0012");
 if (result)
    Console.write("added ACMEdvwks0012 for Joe");
 else
    Console.write("could not add ACMEdvwks0012");
}
catch(Exception ex)
{
 //handle the error case
}
finally
{
 client.Close(); //MUST CALL THIS
}

DeleteAuthorisedMachine

bool DeleteAuthorisedMachine(string UserName, string MachineName)

Purpose

Deletes a machine from a user's authorized list of machines using its name.

Inputs

  • UserName – the user name for an authorized user, in the format DomainName\UserName
  • MachineName – the name for the machine to be deleted, in the format DomainName\MachineName

Returns

  • Boolean – success or failure

Example

C#
var client = new assc.AuthorisationServicesSoapClient();
try
{
 var result = client.DeleteAuthorisedMachine("ACME\Joe",
                                             "ACME\ACMEdvwks0012");
 if (result)
    Console.write("removed ACMEdvwks0012 from Joe");
 else
    Console.write("could not remove ACMEdvwks0012");
}
catch(Exception ex)
{
 //handle the error case
}
finally
{
 client.Close(); //MUST CALL THIS
}

GetAuthorisedMachines

String[] GetAuthorisedMachines(string UserName)

Purpose

Gets an array of machine names on a user's authorized list of machines.

Inputs

  • UserName – the user name for an authorized user, in the format DomainName\UserName

Returns

  • A string array containing all the machines the user is authorized to wake up

Example

C#
var client = new assc.AuthorisationServicesSoapClient();
try
{
 var result = client.GetAuthorisedMachines( "ACME\Joe");
 //process results array
}
catch(Exception ex)
{
 //handle the error case
}
finally
{
 client.Close(); //MUST CALL THIS
}

UpdateAuthorisedMachine

bool UpdateAuthorisedMachine(string UserName, string MachineName, string OldMachineName)

Purpose

Updates the name of a currently authorized machine for a user.

Inputs

  • UserName – the user name for an authorized user, in the format DomainName\UserName
  • MachineName – the new name for the machine being updated, in the format DomainName\MachineName
  • OldMachineName – the old name for the machine being updated, in the format DomainName\MachineName

Returns

  • Boolean – success or failure

Example

C#
var client = new assc.AuthorisationServicesSoapClient();
try
{
 var result = client.UpdateAuthorisedMachine( "ACME\Joe",
                                              "ACME\ACMEdvwks0012",
                                              "ACME\ACMEdvwks0017");
 if (result)
    Console.write("updated ACMEdvwks0012");
 else
    Console.write("could not update ACMEdvwks0012");
}
catch(Exception ex)
{
 //handle the error case
}
finally
{
 client.Close(); //MUST CALL THIS
}