Xbasic

a5ws_getUserValuesActiveDirectory Function

Syntax

dim userValues as P = a5ws_GetUserValuesActiveDirectory([C UserName [,C AdditionalAttributes ]])

Arguments

UserNameCharacter

The user to lookup.

The UserName is required if a5ws_getUserValuesActiveDirectory() is used in Alpha Anywhere 4.4.4 or prior. Starting with Alpha Anywhere build 4449, the user name is optional. If no user name is specified, values for the currently logged in user will be fetched.
AdditionalAttributesCharacter

A comma or CR-LF delimited list of additional properties to retrieve that are available in Active Directory but are not listed by default. See http://www.kouti.com/tables/userattributes.htm for a list of possible properties that may be available.

Returns

userValuesPointer

Returns a dot variable with the properties listed below plus any additional properties requested using the AdditionalAttributes parameter. If the Alpha Anywhere Application Server is not configured to use Active Directory, the Active Directory server cannot be reached, or the user does not exist, no properties will be returned.

If a property has no value, it will have a type of Z.

AccountExpirationDateTime

The account's expiration date.

AccountLockedOutLogical

Indicates whether or not the account is locked.

AccountLockoutTimeTime

LDAP lockout time

BadLogonCountNumeric

The number of failed login attempts.

DescriptionCharacter

Typically a job description or some other user defined information.

DisplayNameCharacter

The account display name.

DistinguishedNameCharacter

The LDAP address for the user (see https://technet.microsoft.com/en-us/library/cc977992.aspx for more information.)

EmailAddressCharacter

The user's email address.

EmployeeIdCharacter

The employee ID.

EnabledLogical

Indicates whether or not the user is active in Active Directory.

GivenNameCharacter

The user's first name.

GuidCharacter

LDAP object GUID - A modified unique identifier with hyphens removed, similar to the userGuid in Alpha Anywhere security. Unique for each user and doesn't change.

HomeDirectoryCharacter

The path to the user's home directory. See https://msdn.microsoft.com/en-us/library/ms676190(v=vs.85).aspx for more information.

HomeDriveCharacter

The home drive.

LastBadPasswordAttemptTime

The time for the last time the login failed due to incorrect password.

LastLogonTime

The time the user last logged on.

LastPasswordSetTime

The last password set for the user's account.

MiddleNameCharacter

The user's middle name.

NameCharacter

The user's full name - first and last name.

PasswordNeverExpiresLogical

Indicates whether or not the password expires.

PasswordNotRequiredLogical

Indicates whether or not a password is required.

RolesCharacter

A CR-LF delimited list of the user's roles.

SamAccountNameCharacter

The user logon name.

ScriptPathCharacter

The path to the login script.

SidCharacter

LDAP ObjectSid - A system identifier and can change for a user. See https://technet.microsoft.com/en-us/library/cc961625.aspx for more details.

SmartcardLogonRequiredLogical

If .t., two-factor authentication is required to logon. See https://blogs.technet.microsoft.com/poshchap/2015/05/08/security-focus-resetting-smart-card-is-required-for-interactive-logon/ for more information.

SurnameCharacter

The user's last name.

UserCannotChangePasswordLogical

Indicate whether or not the user can change their password.

UserPrincipalNameCharacter

The user's name in Active Directory. This is the login name + domain. For example [email protected].

VoiceTelephoneNumberCharacter

The user's telephone number.

Description

Get the Active Directory properties for a user. Alpha Anywhere must be configured to use active directory.

Discussion

The a5ws_getUserValuesActiveDirectory function returns a list of properties for the specified user. A default set of properties is always returned. Proeprties that are available in Active Directory but are not included by default can also be retrieved by passing the list of additional attributes into the AdditionalAttributes parameter.

Examples 

This example demonstrates how to get the phone number for the currently logged in user. The property is a default property, VoiceTelephoneNumber:

dim user as p
dim phone as c
user = a5ws_GetUserValuesActiveDirectory("")
'--- optional method to pass in current user
'user = a5ws_GetUserValuesActiveDirectory(Context.Security.CurrentUser)
if variable_exists("user.SamAccountName") ' User data was found
    phone = user.VoiceTelephoneNumber
else
    'error - no user data found
end if

This next example demonstrates how to get the phone number for a specific user:

dim user as p
dim phone as c
user = a5ws_GetUserValuesActiveDirectory("UserLoginName")
if variable_exists("user.SamAccountName") ' User data was found
    phone = user.VoiceTelephoneNumber
end if

This example demonstrates getting an optional parameter (physicalDeliveryOfficeName):

dim user as p
dim office as c
user = a5ws_GetUserValuesActiveDirectory("","physicalDeliveryOfficeName")
if variable_exists("user.SamAccountName") ' User data was found
    office= user.physicalDeliveryOfficeName
end if

In this example, two optional parameters are fetched (physicalDeliveryOfficeName and homePhone):

dim user as p
dim office as c
dim home_phone as c
user = a5ws_GetUserValuesActiveDirectory("","physicalDeliveryOfficeName,homePhone")
if variable_exists("user.SamAccountName") ' User data was found
    office= user.physicalDeliveryOfficeName
    home_phone = user.homePhone
end if

If the additional properties is too long, the values can be passed in as a list:

dim addProps as c
addProps = <<%txt%
physicalDeliveryOfficeName
homePhone
%txt%

dim user as p
dim UserLoginName as c = "jsmith"
dim office as c
dim home_phone as c
user = a5ws_GetUserValuesActiveDirectory(UserLoginName ,addProps)
if variable_exists("user.SamAccountName") ' User data was found
    office= user.physicalDeliveryOfficeName
    home_phone = user.homePhone
end if