# LDAP Account Manager

# lib/account.inc

# Properties

author
author
package

## Description

This provides several helper function for the account modules.

## Functions

### array_delete( array $values, array $array, ) : array

#### Description

This function will return all values from $array without values of $values.

#### Arguments

Name | Type | Description | Default
--- | --- | --- | ---
$values | array | list of values which should be removed |
$array | array | list of original values |

#### Return value

Type | Description
--- | ---
array | list of remaining values

### in_array_ignore_case( String $needle, array $haystack, ) : n/a

#### Description

Checks if a string exists in an array, ignoring case.

#### Arguments

Name | Type | Description | Default
--- | --- | --- | ---
$needle | String | search string |
$haystack | array | array |

#### Return value

Type | Description
--- | ---
n/a | n/a

### getdays( ) : \number

#### Description

This function will return the days from 1.1.1970 until now.

#### Return value

Type | Description
--- | ---
\number | of days

### smbflag( array $input, ) : string

#### Description

Takes a list of Samba flags and creates the corresponding flag string.

#### Arguments

Name | Type | Description | Default
--- | --- | --- | ---
$input | array | is an array of Samba flags (e.g. X or D) |

#### Return value

Type | Description
--- | ---
string | Samba flag string

### lmPassword( $password, ) : string

#### Description

Generates the LM hash of a password.

#### Arguments

Name | Type | Description | Default
--- | --- | --- | ---
$password | n/a |  |

#### Return value

Type | Description
--- | ---
string | password hash

### ntPassword( $password, ) : string

#### Description

Generates the NT hash of a password.

#### Arguments

Name | Type | Description | Default
--- | --- | --- | ---
$password | n/a |  |

#### Return value

Type | Description
--- | ---
string | password hash

### pwd_hash( string $password, boolean $enabled = true, string $hashType = 'SSHA', ) : string

#### Description

Returns the hash value of a plain text password.

#### Arguments

Name | Type | Description | Default
--- | --- | --- | ---
$password | string | the password string |
$enabled | boolean | marks the hash as enabled/disabled (e.g. by prefixing "!") | true
$hashType | string | password hash type (CRYPT, CRYPT-SHA512, SHA, SSHA, MD5, SMD5, PLAIN) | 'SSHA'

#### Return value

Type | Description
--- | ---
string | the password hash

#### Tags

Name | Description
--- | ---
see |

### getSupportedHashTypes( ) : array

#### Description

Returns the list of supported hash types (e.g. SSHA).

#### Return value

Type | Description
--- | ---
array | hash types

### generateSalt( int $len, ) : String

#### Description

Calculates a password salt of the given legth.

#### Arguments

Name | Type | Description | Default
--- | --- | --- | ---
$len | int | salt length |

#### Return value

Type | Description
--- | ---
String | the salt string

### pwd_enable( string $hash, ) : string

#### Description

Marks an password hash as enabled and returns the new hash string

#### Arguments

Name | Type | Description | Default
--- | --- | --- | ---
$hash | string | hash value to enable |

#### Return value

Type | Description
--- | ---
string | enabled password hash

### pwd_disable( string $hash, ) : string

#### Description

Marks an password hash as disabled and returns the new hash string

#### Arguments

Name | Type | Description | Default
--- | --- | --- | ---
$hash | string | hash value to disable |

#### Return value

Type | Description
--- | ---
string | disabled hash value

### pwd_is_lockable( String $password, ) : boolean

#### Description

Checks if a Unix password can be locked.
This checks if the password is not plain text but e.g. contains {SSHA}.

#### Arguments

Name | Type | Description | Default
--- | --- | --- | ---
$password | String | password value |

#### Return value

Type | Description
--- | ---
boolean | can be locked

### pwd_is_enabled( string $hash, ) : boolean

#### Description

Checks if a password hash is enabled/disabled

#### Arguments

Name | Type | Description | Default
--- | --- | --- | ---
$hash | string | password hash to check |

#### Return value

Type | Description
--- | ---
boolean | true if the password is marked as enabled

### generateRandomPassword( ) : String

#### Description

Generates a random password with 12 digits.

#### Return value

Type | Description
--- | ---
String | password

### checkPasswordHash( $type, \unknown_type $hash, \unknown_type $password, ) : n/a

#### Description

Checks if the given password mathes the crypto hash.

#### Arguments

Name | Type | Description | Default
--- | --- | --- | ---
$type | n/a |  |
$hash | \unknown_type | password hash value |
$password | \unknown_type | plain text password to check |

#### Return value

Type | Description
--- | ---
n/a | n/a

#### Tags

Name | Description
--- | ---
see |

### search_domains( $server = null, String $suffix = null, ) : array

#### Description

Returns an array with all Samba 3 domain entries under the given suffix

#### Arguments

Name | Type | Description | Default
--- | --- | --- | ---
$server | n/a |  | null
$suffix | String | LDAP suffix to search (if null then $_SESSION['config']->get_Suffix('smbDomain') is used) | null

#### Return value

Type | Description
--- | ---
array | list of samba3domain objects

### get_preg( string $argument, string $regexp, ) : boolean

#### Description

Checks if a given value matches the selected regular expression.

#### Arguments

Name | Type | Description | Default
--- | --- | --- | ---
$argument | string | value to check |
$regexp | string | pattern name |

#### Return value

Type | Description
--- | ---
boolean | true if matches, otherwise false

### escapeDN( String $dn, ) : String

#### Description

Escapes any special characters in an LDAP DN.

#### Arguments

Name | Type | Description | Default
--- | --- | --- | ---
$dn | String | DN |

#### Return value

Type | Description
--- | ---
String | escaped DN

### searchLDAPByAttribute( String $name, String $value, String $objectClass, array $attributes, array $scopes, ) : array

#### Description

This will search the given LDAP suffix for all entries which have the given attribute.

#### Arguments

Name | Type | Description | Default
--- | --- | --- | ---
$name | String | attribute name (may be null) |
$value | String | attribute value |
$objectClass | String | object class (may be null) |
$attributes | array | list of attributes to return |
$scopes | array | account types |

#### Return value

Type | Description
--- | ---
array | list of found entries

### searchLDAPByFilter( String $filter, array $attributes, array $scopes, boolean $attrsOnly = false, ) : array

#### Description

This will search the given LDAP suffix for all entries which match the given filter.

#### Arguments

Name | Type | Description | Default
--- | --- | --- | ---
$filter | String |  |
$attributes | array | list of attributes to return |
$scopes | array | account types |
$attrsOnly | boolean | get only attributes but no values (default: false) | false

#### Return value

Type | Description
--- | ---
array | list of found entries

### searchLDAP( String $suffix, String $filter, array $attributes, ) : array

#### Description

Runs an LDAP search.

#### Arguments

Name | Type | Description | Default
--- | --- | --- | ---
$suffix | String | LDAP suffix |
$filter | String | filter |
$attributes | array | list of attributes to return |

#### Return value

Type | Description
--- | ---
array | list of found entries

### ldapGetDN( String $dn, array $attributes = array('dn'), \handle $handle = null, ) : array

#### Description

Returns the given DN.

#### Arguments

Name | Type | Description | Default
--- | --- | --- | ---
$dn | String | DN |
$attributes | array | list of attributes to fetch | array('dn')
$handle | \handle | LDAP handle (optional for admin interface pages) | null

#### Return value

Type | Description
--- | ---
array | attributes or null if not found

### getLastLDAPError( ) : array

#### Description

Returns the parameters for a StatusMessage of the last LDAP search.

#### Return value

Type | Description
--- | ---
array | parameters for StatusMessage or null if all was ok

### cleanLDAPResult( array $entries, ) : n/a

#### Description

Cleans the result of an LDAP search.
This will remove all 'count' entries and also all numeric array keys.

#### Arguments

Name | Type | Description | Default
--- | --- | --- | ---
$entries | array | LDAP entries in format $entries[entry number][attribute name][attribute values] |

#### Return value

Type | Description
--- | ---
n/a | n/a

### getAbstractDN( String $dn, ) : String

#### Description

Transforms a DN into a more user friendly format.
E.g. "dc=company,dc=de" is transformed to "company > de".

#### Arguments

Name | Type | Description | Default
--- | --- | --- | ---
$dn | String | DN |

#### Return value

Type | Description
--- | ---
String | transformed DN

### compareDN( string $a, string $b, ) : integer

#### Description

Helper function to sort DNs.

#### Arguments

Name | Type | Description | Default
--- | --- | --- | ---
$a | string | first argument to compare |
$b | string | second argument to compare |

#### Return value

Type | Description
--- | ---
integer | 0 if equal, 1 if $a is greater, -1 if $b is greater

### formatLDAPTimestamp( String $time, ) : String

#### Description

Formats an LDAP time string (e.g. from createTimestamp).

#### Arguments

Name | Type | Description | Default
--- | --- | --- | ---
$time | String | LDAP time value |

#### Return value

Type | Description
--- | ---
String | formated time

### obfuscateText( String $text, ) : n/a

#### Description

Simple function to obfuscate strings.

#### Arguments

Name | Type | Description | Default
--- | --- | --- | ---
$text | String | text to obfuscate |

#### Return value

Type | Description
--- | ---
n/a | n/a

### deobfuscateText( String $text, ) : n/a

#### Description

Simple function to deobfuscate strings.

#### Arguments

Name | Type | Description | Default
--- | --- | --- | ---
$text | String | text to deobfuscate |

#### Return value

Type | Description
--- | ---
n/a | n/a

### isObfuscatedText( String $text, ) : boolean

#### Description

Checks if the given text is obfuscated.

#### Arguments

Name | Type | Description | Default
--- | --- | --- | ---
$text | String | text to check |

#### Return value

Type | Description
--- | ---
boolean | obfuscated or not

### extractRDNAttribute( String $dn, ) : String

#### Description

Extracts the RDN attribute name from a given DN.

#### Arguments

Name | Type | Description | Default
--- | --- | --- | ---
$dn | String | DN |

#### Return value

Type | Description
--- | ---
String | RDN attribute name

### extractRDNValue( String $dn, ) : String

#### Description

Extracts the RDN attribute value from a given DN.

#### Arguments

Name | Type | Description | Default
--- | --- | --- | ---
$dn | String | DN |

#### Return value

Type | Description
--- | ---
String | RDN attribute value

### extractDNSuffix( String $dn, ) : String

#### Description

Extracts the DN suffix from a given DN.
E.g. ou=people,dc=test,dc=com will result in dc=test,dc=com.

#### Arguments

Name | Type | Description | Default
--- | --- | --- | ---
$dn | String | DN |

#### Return value

Type | Description
--- | ---
String | DN suffix

### sendPasswordMail( String $pwd, array $user, String $recipient = null, ) : array

#### Description

Sends the password mail.

#### Arguments

Name | Type | Description | Default
--- | --- | --- | ---
$pwd | String | new password |
$user | array | LDAP attributes of user |
$recipient | String | recipient address (optional, $user['mail'][0] used by default) | null

#### Return value

Type | Description
--- | ---
array | list of arrays that can be used to create status messages

### createEMailHeaders( String $from, boolean $isHTML, String $replyTo = null, ) : n/a

#### Description

Generates the email header text for the given parameters.

#### Arguments

Name | Type | Description | Default
--- | --- | --- | ---
$from | String | FROM address |
$isHTML | boolean | mail is formatted as HTML or plain text |
$replyTo | String | reply-to address (optional) | null

#### Return value

Type | Description
--- | ---
n/a | n/a

### base64EncodeForEMail( String $value, ) : String

#### Description

Returns a base64 encoded string of the given values in a fomat that is used in emails.

#### Arguments

Name | Type | Description | Default
--- | --- | --- | ---
$value | String | value to encode |

#### Return value

Type | Description
--- | ---
String | base64 encoded value

### getRandomNumber( ) : int

#### Description

Returns a random number.

#### Return value

Type | Description
--- | ---
int | random number

### getLDAPSSLCertificate( String $server, String $port, ) : mixed

#### Description

Connects to the LDAP server and extracts the certificates.

#### Arguments

Name | Type | Description | Default
--- | --- | --- | ---
$server | String | server name |
$port | String | server port |

#### Return value

Type | Description
--- | ---
mixed | false on error and certificate if extracted successfully

### getExtendedLDAPErrorMessage( \handle $server, ) : String

#### Description

Returns the extended LDAP error message if any.

#### Arguments

Name | Type | Description | Default
--- | --- | --- | ---
$server | \handle | LDAP server handle |

#### Return value

Type | Description
--- | ---
String | error message

## Classes

### samba3domain

# Properties

Extends
Implements
package
modules
Abstract
No
Final
No

#### Description

Represents a Samba 3 domain entry

#### Properties

$RIDbase, $SID, $dn, $maxPwdAge, $minPwdAge, $name, $nextGroupRID, $nextRID, $nextUserRID,

### public $RIDbase = 1000

RID base to calculate RIDs, default 1000

### public $SID =

Domain SID

### public $dn =

DN

### public $maxPwdAge =

seconds after the password must be changed

### public $minPwdAge =

seconds after the password can be changed

### public $name =

Domain name

### public $nextGroupRID =

Next group RID

### public $nextRID =

Next RID

### public $nextUserRID =

Next user RID

### moduleCache

# Properties

Extends
Implements
author
Roland Gruber
Abstract
No
Final
No

#### Description

Caches module objects.
This improves performance if the same module does not need to be created multiple times (calling get_metaData() each time).

#### Methods

getModule,

### getModule( String $name, String $scope, ) : n/a

#### Description

Returns a new/cached module with the given name and scope.

#### Arguments

Name | Type | Description | Default
--- | --- | --- | ---
$name | String | module name |
$scope | String | module scope (e.g. user) |

#### Return value

Type | Description
--- | ---
n/a | n/a

#### Properties

$cache,

### private static $cache = array()

module cache ("name:scope" => module)
Documentation was generated by phpDocumentor 2.0.1 .

# Namespaces

- global

# Packages

- Crypt_AES
  - Crypt_AES
    Pure-PHP implementation of AES.
- Crypt_DES
  - Crypt_DES
    Pure-PHP implementation of DES.
- Crypt_Hash
  - Crypt_Hash
    Pure-PHP implementations of keyed-hash message authentication codes (HMACs) and various cryptographic hashing functions.
- Crypt_RC4
  - Crypt_RC4
    Pure-PHP implementation of RC4.
- Crypt_RSA
  - Crypt_RSA
    Pure-PHP PKCS#1 compliant implementation of RSA.
- Crypt_Random
- Crypt_Rijndael
  - Crypt_Rijndael
    Pure-PHP implementation of Rijndael.
- Crypt_TerraDES
  - Crypt_TripleDES
    Pure-PHP implementation of Triple DES.
- Crypt_TripleDES
- Help
- LDAP
  - Ldap
    Ldap manages connection to LDAP and includes several helper functions.
- Math_BigInteger
  - Math_BigInteger
    Pure-PHP arbitrary precision integer arithmetic library. Supports base-2, base-10, base-16, and base-256 numbers.
- Net_SFTP
  - Net_SFTP
    Pure-PHP implementations of SFTP.
- Net_SSH1
  - Net_SSH1
    Pure-PHP implementation of SSHv1.
- Net_SSH2
  - Net_SSH2
    Pure-PHP implementation of SSHv2.
- PDF
  - UFPDF
    Main UFPDF class for creating Unicode PDF documents
  - lamPDF
    Creates a LAM information page in PDF format.
  - xmlParser
    Simple XML parser.
- PHP_Compat
- configuration
  - LAMCfgMain
    This class manages config.cfg.
  - LAMConfig
    This class manages .conf files.
- horde.cipher
  - Horde_Cipher_blowfish
- lam
  - smbHash
    Calculates NT and LM hashes.
- lib
  - AttributeType
    Represents an LDAP AttributeType
  - MatchingRule
    Represents an LDAP MatchingRule
  - MatchingRuleUse
    Represents an LDAP schema matchingRuleUse entry
  - ObjectClass
    Represents an LDAP objectClass
  - ObjectClassAttribute
    A simple class for representing AttributeTypes used only by the ObjectClass class.
  - SchemaItem
    Generic parent class for all schema items. A schema item is an ObjectClass, an AttributeBype, a MatchingRule, or a Syntax.
  - Syntax
    Represents an LDAP Syntax
- lists
  - lamAsteriskExtList
    Generates the list view.
  - lamBooleanListOption
    Boolean option for list configuration.
  - lamDHCPList
    Generates the list view.
  - lamGroupList
    Generates the list view.
  - lamHostList
    Generates the list view.
  - lamList
    Generates the list view.
  - lamListOption
    Represents a list configuration option.
  - lamListTool
    Represents a tool which can be included in the account lists.
  - lamMailAliasList
    Generates the list view.
  - lamNetgroupList
    Generates the list view.
  - lamSelectListOption
    Boolean option for list configuration.
  - lamSmbDomainList
    Generates the list view.
  - lamUserList
    Generates the list view.
- main
- metaHTML
  - htmlAccountPageButton
    Prints a button for the account pages.
  - htmlButton
    Simple button.
  - htmlDiv
    Creates a simple DIV element.
  - htmlElement
    Represents a HTML element.
  - htmlEqualHeight
    Sets all given elements to the same height.
  - htmlEqualWidth
    Sets all given elements to the same width.
  - htmlFieldset
    Generates a fieldset.
  - htmlGroup
    Groups multiple htmlElements.
  - htmlHelpLink
    Renders a help link.
  - htmlHiddenInput
    Generates a hidden input field.
  - htmlHorizontalLine
    Prints a horizontal line.
  - htmlImage
    Prints the HTML code for an image.
  - htmlInputCheckbox
    Prints the HTML code for a checkbox.
  - htmlInputField
    A standard input field.
  - htmlInputFileUpload
    Prints the HTML code for a file upload field.
  - htmlInputTextarea
    Prints the HTML code for a textarea.
  - htmlJavaScript
    Creates a JavaScript element.
  - htmlLink
    Generates a link.
  - htmlOutputText
    Prints the text and escapes contained HTML code by default.
  - htmlRadio
    Represents a radio selection.
  - htmlSelect
    Represents a select box.
  - htmlSortableList
    Creates a list of elements that can be sorted by the user via drag'n'drop.
  - htmlSpacer
    Adds an empty space with given width and height.
  - htmlStatusMessage
    Prints a status message (e.g. error message).
  - htmlSubTitle
    Generates a subtitle line. This is used to group multiple fields.
  - htmlTable
    Structures elements using a table.
  - htmlTableExtendedInputCheckbox
    Checkbox with descriptive label and help link.
  - htmlTableExtendedInputField
    An extended input field that combines label, input field and help.
  - htmlTableExtendedInputFileUpload
    File upload with descriptive label and help link.
  - htmlTableExtendedInputTextarea
    Text area with label and help link.
  - htmlTableExtendedRadio
    Radio list with descriptive label and help link.
  - htmlTableExtendedSelect
    Select with label and help link.
  - htmlTableRow
    A row inside a htmlTable.
  - htmlTitle
    Generates a title line. This is used for page titles.
- modules
  - account
    Manages the object class "account" for users and hosts.
  - accountContainer
    This class includes all modules and attributes of an account.
  - asteriskAccount
    Manages the Asterisk extension of user accounts.
  - asteriskExtension
    Manages Asterisk extensions.
  - asteriskVoicemail
    Manages the Asterisk extension of user accounts.
  - authorizedServiceObject
    Provides Authorized Service for accounts.
  - baseModule
    Parent class of all account modules.
  - ddns
    Manages DDNS entries.
  - dhcp_settings
    Manages DHCP entries.
  - eduPerson
    Manages the eduPerson extension for user accounts.
  - fixed_ip
    Manages DHCP host entries.
  - freeRadius
    Manages FreeRadius accounts.
  - generalInformation
    Shows general information like the creation time of an account.
  - hostObject
    Manages the hosts to which a user may login.
  - ieee802device
    Provides MAC addresses for hosts.
  - imapAccess
    Manages mailboxes on an IMAP server.
  - inetLocalMailRecipient
    Provides mail routing for users.
  - inetOrgPerson
    This module manages LDAP attributes of the object class inetOrgPerson (e.g. name and address).
  - kolabGroup
    Manages Kolab group accounts.
  - kolabUser
    Manages Kolab user accounts.
  - ldapPublicKey
    Manages SSH public keys.
  - nisMailAlias
    Provides NIS mail alias management.
  - nisnetgroup
    Manages entries based on the object class nisNetgroup.
  - passwordService
    This interface needs to be implemented by all account modules which manage passwords.
  - posixAccount
    Manages the object class "posixAccount" for users and hosts.
  - posixGroup
    Manages the object class "posixGroup" for groups.
  - puppetClient
    Manages Puppet configuration options.
  - quota
    Manages quotas for users and groups.
  - range
    Manages DHCP ranges for DHCP server.
  - samba3domain
    Represents a Samba 3 domain entry
  - sambaDomain
    Manages Samba 3 domain entries.
  - sambaGroupMapping
    Manages the object class "sambaGroupMapping" for groups.
  - sambaMungedDial
    Manages terminal server settings for Samba 3.
  - sambaSamAccount
    Manages the object class "sambaSamAccount" for users and hosts.
  - shadowAccount
    Manages the object class "shadowAccount" for users.
  - smbHash
    Calculates NT and LM hashes.
  - systemQuotas
    Manages user quotas with the object class systemQuotas.
  - windowsGroup
    Manages Windows AD (e.g. Samba 4) groups.
  - windowsHost
    Manages Windows AD (e.g. Samba 4) hosts.
  - windowsPosixGroup
    Manages Unix groups in Windows LDAP schema.
  - windowsUser
    Manages Windows AD (e.g. Samba 4) users.
- phpLDAPadmin
- profiles
- selfService
  - selfServiceProfile
    Includes all settings of a self service profile.
- tools
  - LAMSubTool
    Represents a subtool.
  - LAMTool
    Represents a tool.
  - toolFileUpload
    File upload
  - toolOUEditor
    OU editor
  - toolPDFEditor
    PDF editor
  - toolProfileEditor
    Profile editor
  - toolSchemaBrowser
    Schema browser
  - toolServerInformation
    Server information
  - toolTests
    Tests page
- types
  - asteriskExt
    The account type for Asterisk extensions.
  - baseType
    This is the parent class of all account types.
  - dhcp
    The account type for DHCP
  - group
    The account type for group accounts (e.g. Unix and Samba).
  - host
    The account type for host accounts (e.g. Samba).
  - mailAlias
    The account type for mail aliases.
  - netgroup
    The account type for NIS netgroups.
  - smbDomain
    The account type for Samba domains.
  - user
    The account type for user accounts (e.g. Unix, Samba and Kolab).