LDAP Account Manager

accountContainer
in package

This class includes all modules and attributes of an account.

Table of Contents

$attributes  : array<string|int, mixed>|null
$attributes_orig  : array<string|int, mixed>|null
$dn_orig  : string|null
$dnSuffix  : string|null
DN suffix of the account
$finalDN  : string|null
DN of saved account
$isNewAccount  : bool
True if this is a newly created account
$rdn  : string|null
RDN attribute of this account
$base  : string
Name of accountContainer variable in session
$cachedOUs  : array<string|int, mixed>|null
$current_page  : int
This variable stores the page number of the currently displayed page
$extraInfoAttributes  : array<string|int, mixed>
$lastLoadedProfile  : string
name of last loaded account profile
$module  : array<string|int, mixed>
This is an array with all module objects
$order  : array<string|int, mixed>|null
$postSaveErrorsOccurred  : bool
$sendPasswordViaMail  : string|null
password to send via mail
$sendPasswordViaMailAlternateAddress  : string|null
send password via mail to this alternate address
$sendPasswordViaSms  : string|null
password to send via SMS
$subpage  : string
This variable is set to the pagename of a subpage if it should be displayed
$titleBarIcon  : htmlElement|null
icon in title bar
$titleBarSubtitle  : string
subtitle in title bar
$titleBarTitle  : string|null
main title in title bar
$type  : ConfiguredType
This variable stores the account type.
__construct()  : mixed
Constructor
__serialize()  : array<string, mixed>
Encrypts sensitive data before storing in session.
__unserialize()  : void
Decrypts sensitive data after accountContainer was loaded from session.
continue_main()  : void
This function is called when the user clicks on any button on the account pages.
copyFromExistingAccount()  : void
Copies the data from the given account to this one.
fixLDAPAttributes()  : array<string, string[]|string>
Fixes spelling errors in the attribute names.
get_pdfEntries()  : array<string, array<string|int, PDFEntry>>
Returns a list of possible PDF entries for this account.
get_type()  : ConfiguredType
Returns the account type of this object (e.g. user, group, host).
getAccountModule()  : T|null
Returns the account module with the given class name
getAccountModules()  : array<string|int, baseModule>
Returns the included account modules.
getEditKey()  : string
Returns the session edit key for this container.
getOUs()  : array<string|int, string>
Returns a list of OUs that exist for this account type.
getRDN()  : string
Returns the RDN part of a given DN.
hasOnlyVirtualChildren()  : bool
Defines if the LDAP entry has only virtual child entries. This is the case for e.g. LDAP views.
initModules()  : void
Creates the account modules and initializes them.
load_account()  : array<string|int, array<string|int, string|string[]>>
Loads an LDAP account with the given DN.
new_account()  : void
This function will prepare the object for a new account.
replaceWildcardsInArray()  : void
Replaces data with wildcard values from modules.
replaceWildcardsInPOST()  : void
Replaces POST data with wildcard values from modules.
save_module_attributes()  : array<string, array<string, array<string, array<string|int, string>>>>
This function checks which LDAP attributes have changed while the account was edited.
setNewPassword()  : array<string, bool|string>
Sets the new password in all selected account modules.
anyModuleManagesMail()  : bool
Returns if any module manages the mail attribute.
doReplace()  : bool
Replaces wildcards in a value.
getParentDN()  : string
Returns the parent DN of a given DN.
loadProfileIfRequested()  : bool
Checks if the user requested to load a profile.
printCommonControls()  : void
Prints common controls like the save button and the ou selection.
printModuleContent()  : void
Prints the content part provided by the current module.
printModuleTabs()  : void
Prints the HTML code of the module tabs.
printPageFooter()  : void
Prints the footer of the account pages.
printPageHeader()  : void
Prints the header of the account pages.
printPasswordPromt()  : void
Prints the input fields of the central password service.
printSuccessPage()  : void
Prints the HTML code to notify the user about the successful saving.
replaceWildcards()  : bool
Replaces wildcards in an array.
save_account()  : array<string|int, array<string|int, string|string[]>>
This function will save an account to the LDAP database.
showSetPasswordButton()  : bool
Returns if the page should show a button to set the password.
sortModules()  : void
Sorts the module buttons for the account page.

Properties

$attributes

public array<string|int, mixed>|null $attributes = \null

Array of all used attributes Syntax is attribute => array ( objectClass => MUST or MAY, ...)

$attributes_orig

public array<string|int, mixed>|null $attributes_orig = \null

original LDAP attributes when account was loaded from LDAP

$dn_orig

public string|null $dn_orig = \null

DN of account when it was loaded

$dnSuffix

DN suffix of the account

public string|null $dnSuffix = \null

$finalDN

DN of saved account

public string|null $finalDN = \null

$isNewAccount

True if this is a newly created account

public bool $isNewAccount = \false

$rdn

RDN attribute of this account

public string|null $rdn = \null

$base

Name of accountContainer variable in session

private string $base

$cachedOUs

private array<string|int, mixed>|null $cachedOUs = \null

cache for existing OUs

$current_page

This variable stores the page number of the currently displayed page

private int $current_page = 0

$extraInfoAttributes

private array<string|int, mixed> $extraInfoAttributes = []

additional attributes for pre/post actions

$lastLoadedProfile

name of last loaded account profile

private string $lastLoadedProfile = ''

$module

This is an array with all module objects

private array<string|int, mixed> $module = []

modules

$order

private array<string|int, mixed>|null $order = \null

module order

$postSaveErrorsOccurred

private bool $postSaveErrorsOccurred = \false

errors occurred after saving LDAP data (postModify scripts)

$sendPasswordViaMail

password to send via mail

private string|null $sendPasswordViaMail = \null

$sendPasswordViaMailAlternateAddress

send password via mail to this alternate address

private string|null $sendPasswordViaMailAlternateAddress = \null

$sendPasswordViaSms

password to send via SMS

private string|null $sendPasswordViaSms = \null

$subpage

This variable is set to the pagename of a subpage if it should be displayed

private string $subpage = 'attributes'

$titleBarSubtitle

subtitle in title bar

private string $titleBarSubtitle = ''

$titleBarTitle

main title in title bar

private string|null $titleBarTitle = \null

Methods

__construct()

Constructor

public __construct(ConfiguredType $type, string $base) : mixed
Parameters
$type : ConfiguredType

account type

$base : string

key in $_SESSION where this object is saved

Return values
mixed

__serialize()

Encrypts sensitive data before storing in session.

public __serialize() : array<string, mixed>
Return values
array<string, mixed>

data

__unserialize()

Decrypts sensitive data after accountContainer was loaded from session.

public __unserialize(array<string, mixed> $data) : void
Parameters
$data : array<string, mixed>

data

Return values
void

continue_main()

This function is called when the user clicks on any button on the account pages.

public continue_main() : void

It prints the HTML code of each account page.

Return values
void

copyFromExistingAccount()

Copies the data from the given account to this one.

public copyFromExistingAccount(string $copyDn) : void
Parameters
$copyDn : string

DN to copy from

Return values
void

fixLDAPAttributes()

Fixes spelling errors in the attribute names.

public fixLDAPAttributes(array<string, string[]|string>|null $attributes, array<string|int, string> $modules) : array<string, string[]|string>
Parameters
$attributes : array<string, string[]|string>|null

LDAP attributes

$modules : array<string|int, string>

list of active modules

Return values
array<string, string[]|string>

fixed attributes

get_pdfEntries()

Returns a list of possible PDF entries for this account.

public get_pdfEntries(array<string|int, string> $pdfKeys, string $typeId) : array<string, array<string|int, PDFEntry>>
Parameters
$pdfKeys : array<string|int, string>

list of PDF keys that are included in document

$typeId : string

type id (user, group, host)

Return values
array<string, array<string|int, PDFEntry>>

list of key => PDFEntry

get_type()

Returns the account type of this object (e.g. user, group, host).

public get_type() : ConfiguredType
Return values
ConfiguredType

account type

getAccountModule()

Returns the account module with the given class name

public getAccountModule(class-string<\T> $name) : T|null
Parameters
$name : class-string<\T>

class name (e.g. posixAccount)

Tags
template

T of baseModule

Return values
T|null

account module

getAccountModules()

Returns the included account modules.

public getAccountModules() : array<string|int, baseModule>
Return values
array<string|int, baseModule>

modules

getEditKey()

Returns the session edit key for this container.

public getEditKey() : string
Return values
string

key

getOUs()

Returns a list of OUs that exist for this account type.

public getOUs() : array<string|int, string>
Return values
array<string|int, string>

OU list

getRDN()

Returns the RDN part of a given DN.

public getRDN(string|null $dn) : string
Parameters
$dn : string|null

DN

Return values
string

RDN

hasOnlyVirtualChildren()

Defines if the LDAP entry has only virtual child entries. This is the case for e.g. LDAP views.

public hasOnlyVirtualChildren() : bool
Return values
bool

has only virtual children

initModules()

Creates the account modules and initializes them.

public initModules() : void
Return values
void

load_account()

Loads an LDAP account with the given DN.

public load_account(string $dn[, array<string, string> $infoAttributes = [] ]) : array<string|int, array<string|int, string|string[]>>
Parameters
$dn : string

the DN of the account

$infoAttributes : array<string, string> = []

list of additional informational attributes that are added to the LDAP attributes E.g. this is used to inject the clear text password in the file upload. Informational attribute names must start with "INFO.".

Return values
array<string|int, array<string|int, string|string[]>>

error messages

new_account()

This function will prepare the object for a new account.

public new_account() : void
Return values
void

replaceWildcardsInArray()

Replaces data with wildcard values from modules.

public replaceWildcardsInArray(array<string|int, string> $keyPrefixes, array<string, array|string> &$data) : void
Parameters
$keyPrefixes : array<string|int, string>

POST keys as full name or prefix (e.g. "key" matches "key1")

$data : array<string, array|string>

list of values that need replacement

Return values
void

replaceWildcardsInPOST()

Replaces POST data with wildcard values from modules.

public replaceWildcardsInPOST(array<string|int, string> $keyPrefixes) : void
Parameters
$keyPrefixes : array<string|int, string>

POST keys as full name or prefix (e.g. "key" matches "key1")

Return values
void

save_module_attributes()

This function checks which LDAP attributes have changed while the account was edited.

public save_module_attributes(array<string, string[]|string> $attributes, array<string, string[]|string> $orig) : array<string, array<string, array<string, array<string|int, string>>>>
Parameters
$attributes : array<string, string[]|string>

list of current LDAP attributes

$orig : array<string, string[]|string>

list of old attributes when account was loaded

Return values
array<string, array<string, array<string, array<string|int, string>>>>

an array which can be passed to $this->saveAccount()

setNewPassword()

Sets the new password in all selected account modules.

public setNewPassword(array<string, string|string[]> $input) : array<string, bool|string>
Parameters
$input : array<string, string|string[]>

input parameters

Return values
array<string, bool|string>

result

anyModuleManagesMail()

Returns if any module manages the mail attribute.

private anyModuleManagesMail() : bool
Return values
bool

mail is managed

doReplace()

Replaces wildcards in a value.

private doReplace(array<string, string> $replacements, string &$value) : bool
Parameters
$replacements : array<string, string>

replacements (key => value)

$value : string

value to perform replacements

Return values
bool

replacement done

getParentDN()

Returns the parent DN of a given DN.

private getParentDN(string|null $dn) : string
Parameters
$dn : string|null

DN

Return values
string

DN

loadProfileIfRequested()

Checks if the user requested to load a profile.

private loadProfileIfRequested() : bool
Return values
bool

true, if profile was loaded

printCommonControls()

Prints common controls like the save button and the ou selection.

private printCommonControls() : void
Return values
void

printModuleContent()

Prints the content part provided by the current module.

private printModuleContent(array<string|int, array<string|int, string|string[]>> $result) : void
Parameters
$result : array<string|int, array<string|int, string|string[]>>

list of messages

Return values
void

printModuleTabs()

Prints the HTML code of the module tabs.

private printModuleTabs() : void
Return values
void

printPageFooter()

Prints the footer of the account pages.

private printPageFooter() : void
Return values
void

printPageHeader()

Prints the header of the account pages.

private printPageHeader() : void
Return values
void

printPasswordPromt()

Prints the input fields of the central password service.

private printPasswordPromt() : void
Return values
void

printSuccessPage()

Prints the HTML code to notify the user about the successful saving.

private printSuccessPage(array<string|int, array<string|int, string|string[]>> $messages) : void
Parameters
$messages : array<string|int, array<string|int, string|string[]>>

array which contains status messages. Each entry is an array containing the status message parameters.

Return values
void

replaceWildcards()

Replaces wildcards in an array.

private replaceWildcards(array<string, string> $replacements, array<string|int, string> $keyPrefixes, array<string, array|string> &$data) : bool
Parameters
$replacements : array<string, string>

replacements (key => value)

$keyPrefixes : array<string|int, string>

prefixes of $data array keys that should be replaced

$data : array<string, array|string>

data array

Return values
bool

replacement done

save_account()

This function will save an account to the LDAP database.

private save_account() : array<string|int, array<string|int, string|string[]>>
Return values
array<string|int, array<string|int, string|string[]>>

list of status messages

showSetPasswordButton()

Returns if the page should show a button to set the password.

private showSetPasswordButton() : bool
Return values
bool

show or hide button

sortModules()

Sorts the module buttons for the account page.

private sortModules() : void
Return values
void

Search results