Please enable JavaScript to view this site.

CopiaFacts™ Reference Manual

Look up Active Directory User properties

$ad_get_user property value [property value [property value]]

This command retrieves the set of properties for a User in the Active Directory User hierarchy, and sets CopiaFacts variables for each of the properties selected in the environment variable ADP_PROPERTIES.

The user properties can then be accessed using CopiaFacts variables with names of the form ADU_propertyname.  See also the Active Directory Integration topic for required configuration settings.

If this command is used in a script without a successful AD connection having been made using $ad_connect, a run-time error 5018 will result and the script will fail.

The parameters on this command are used as follows:

propertyThe name of a property which will be used to find the user.  This must be one of the properties specified on the environment variable ADP_PROPERTIES.
valueThe value which is to be matched in the specified property. Character case is ignored.

Up to three sets of match criteria may be supplied; if more than one, then all criteria supplied must match the user's properties.

The name property is handled specially: if both cn and name are included in ADP_PROPERTIES, and if name is specified in the first or only property on the command, then the match will be made against cn if present for the user and against name if not.

If no user can be found to match the property value(s), the value of all the ADU_... variables will be empty, and a variable AD_STATE will be set to a value of 'NOT_MATCHED'; otherwise this variable will contain 'MATCHED' and you will be able to access properties of the user as the values of variables with names ADU_propertyname. If there is more than one matched user, any one of the the matched users might be selected.

If you attempt to access the value of a variable with prefix ADU_ which is not included in ADP_PROPERTIES, or without a successful connection to Active Directory (see $ad_connect) a run-time warning or error will be reported and the value will be returned as empty (unless you have used this name for your own user variable, which is not recommended).

The properties of the matched user remain available in the ADU user variables until the next use of the $ad_get_user command in the call.  A subsequent use of the command resets all variable to empty before setting the values for the new user.

Example:

$ad_get_user mail steve@copia.com

$ifn "@AD_STATE" = "NOT_MATCHED"

  ; handle no match...

$else

  $set_var FAX_DEST @ADU_facsimileTelephoneNumber

$endif

To process the above example, both of the property names mail and faxsimileTelephoneNumber must be in included in the environment variable ADP_PROPERTIES.