lib/account.inc

Properties

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

 
 
modules  
No 
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

 
 
No 
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