GetCommand
Returns the command right with a specified name or GUID.
Syntax
ICommand GetCommand (string name)
ICommand GetCommand (Guid id)
Parameter
Specify one of the following parameters when using this method:
| Parameter | Description |
|---|---|
name
|
The name of the command. |
id
|
The GUID of the command. |
Return value
A command right with the specified name or GUID, or null if no match is found.
Exceptions
GetCommand may throw one of the following exceptions:
-
ApplicationExceptionif it can’t find authorization data for the zone or if it failed to get the command right (see the message returned by the exception for the reason). -
ArgumentExceptionif the name or id parameter isnullor empty.
Example
The following code sample illustrates using the GetCommand method in a script:
...
// Get the zone object
IHierarchicalZone objZone =
cims.GetZoneByPath("cn=" + strZone + "," + strContainerDN) as IHierarchicalZone;
if (objZone == null)
{
Console.WriteLine("Zone " + strZone + " does not exist.");
}
else
{
ICommand objCmd = objZone.GetCommand(strCmd);
if (objCmd != null)
{
Console.WriteLine("Command " + strCmd + " already exists.");
}
else
{
objCmd = objZone.CreateCommand();
objCmd.Name = strCmd;
objCmd.CommandPattern = strPattern;
objCmd.Description = "optional description";
objCmd.Commit();
}
}
...