# LDAP Account Manager

# lib/3rdParty/phpseclib/Net/SFTP.php

# Properties

author
category
copyright
license
link
package

## Description

Pure-PHP implementation of SFTP.
PHP versions 4 and 5 Currently only supports SFTPv3, which, according to wikipedia.org, "is the most widely used version, implemented by the popular OpenSSH SFTP server". If you want SFTPv4/5/6 support, provide me with access to an SFTPv4/5/6 server. The API for this library is modeled after the API from PHP's {@link http://php.net/book.ftp FTP extension}. Here's a short example of how to use this library: `login('username', 'password')) { exit('Login Failed'); } echo $sftp->pwd() . "\r\n"; $sftp->put('filename.ext', 'hello, world!'); print_r($sftp->nlist()); ?>` LICENSE: Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

## Constants

### NET_SFTP_LOG_SIMPLE = NET_SSH2_LOG_SIMPLE

Returns the message numbers

### NET_SFTP_LOG_COMPLEX = NET_SSH2_LOG_COMPLEX

Returns the message content

### NET_SFTP_CHANNEL = 2

SFTP channel constant
Net_SSH2::exec() uses 0 and Net_SSH2::read() / Net_SSH2::write() use 1.

### NET_SFTP_LOCAL_FILE = 1

Reads data from a local file.

### NET_SFTP_STRING = 2

Reads data from a string.

## Classes

### Net_SFTP

# Properties

Extends
Implements
access
public
author
Jim Wigginton <terrafrost@php.net>
package
Net_SFTP
version
Abstract
No
Final
No

#### Description

Pure-PHP implementations of SFTP.

#### Methods

Net_SFTP, _disconnect, _get_sftp_packet, _list, _parseAttributes, _parseLongname, _read_put_responses, _realpath, _send_sftp_packet, _size, _stat, chdir, chmod, delete, get, getLastSFTPError, getSFTPErrors, getSFTPLog, getSupportedVersions, login, lstat, mkdir, nlist, pwd, rawlist, rename, rmdir, size, stat,

### Net_SFTP( String $host, $port = 22, $timeout = 10, ) : \Net_SFTP

#### Description

Default Constructor.
Connects to an SFTP server

#### Arguments

Name | Type | Description | Default
--- | --- | --- | ---
$host | String |  |
$port | n/a |  | 22
$timeout | n/a |  | 10

#### Return value

Type | Description
--- | ---
\Net_SFTP |

#### Tags

Name | Description
--- | ---
access | public

### _disconnect( Integer $reason, ) : Boolean

#### Description

Disconnect

#### Arguments

Name | Type | Description | Default
--- | --- | --- | ---
$reason | Integer |  |

#### Return value

Type | Description
--- | ---
Boolean |

#### Tags

Name | Description
--- | ---
access | private

### _get_sftp_packet( ) : String

#### Description

Receives SFTP Packets
See '6. General Packet Format' of draft-ietf-secsh-filexfer-13 for more info. Incidentally, the number of SSH_MSG_CHANNEL_DATA messages has no bearing on the number of SFTP packets present. There can be one SSH_MSG_CHANNEL_DATA messages containing two SFTP packets or there can be two SSH_MSG_CHANNEL_DATA messages containing one SFTP packet.

#### Return value

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

#### Tags

Name | Description
--- | ---
see |
access | private

### _list( $dir, $raw = true, ) : Mixed

#### Description

Reads a list, be it detailed or not, of files in the given directory

#### Arguments

Name | Type | Description | Default
--- | --- | --- | ---
$dir | n/a |  |
$raw | n/a |  | true

#### Return value

Type | Description
--- | ---
Mixed |

#### Tags

Name | Description
--- | ---
access | private

### _parseAttributes( String $response, ) : Array

#### Description

Parse Attributes
See '7. File Attributes' of draft-ietf-secsh-filexfer-13 for more info.

#### Arguments

Name | Type | Description | Default
--- | --- | --- | ---
$response | String |  |

#### Return value

Type | Description
--- | ---
Array |

#### Tags

Name | Description
--- | ---
access | private

### _parseLongname( String $longname, ) : Mixed

#### Description

Parse Longname
SFTPv3 doesn't provide any easy way of identifying a file type. You could try to open a file as a directory and see if an error is returned or you could try to parse the SFTPv3-specific longname field of the SSH_FXP_NAME packet. That's what this function does. The result is returned using the {@link http://tools.ietf.org/html/draft-ietf-secsh-filexfer-04#section-5.2 SFTPv4 type constants}. If the longname is in an unrecognized format bool(false) is returned.

#### Arguments

Name | Type | Description | Default
--- | --- | --- | ---
$longname | String |  |

#### Return value

Type | Description
--- | ---
Mixed |

#### Tags

Name | Description
--- | ---
access | private

### _read_put_responses( Integer $i, ) : Boolean

#### Description

Reads multiple successive SSH_FXP_WRITE responses
Sending an SSH_FXP_WRITE packet and immediately reading its response isn't as efficient as blindly sending out $i SSH_FXP_WRITEs, in succession, and then reading $i responses.

#### Arguments

Name | Type | Description | Default
--- | --- | --- | ---
$i | Integer |  |

#### Return value

Type | Description
--- | ---
Boolean |

#### Tags

Name | Description
--- | ---
access | private

### _realpath( String $dir, ) : Mixed

#### Description

Canonicalize the Server-Side Path Name
SFTP doesn't provide a mechanism by which the current working directory can be changed, so we'll emulate it. Returns the absolute (canonicalized) path. If $mode is set to NET_SFTP_CONFIRM_DIR (as opposed to NET_SFTP_CONFIRM_NONE, which is what it is set to by default), false is returned if $dir is not a valid directory.

#### Arguments

Name | Type | Description | Default
--- | --- | --- | ---
$dir | String |  |

#### Return value

Type | Description
--- | ---
Mixed |

#### Tags

Name | Description
--- | ---
see |
access | private

### _send_sftp_packet( Integer $type, String $data, ) : Boolean

#### Description

Sends SFTP Packets
See '6. General Packet Format' of draft-ietf-secsh-filexfer-13 for more info.

#### Arguments

Name | Type | Description | Default
--- | --- | --- | ---
$type | Integer |  |
$data | String |  |

#### Return value

Type | Description
--- | ---
Boolean |

#### Tags

Name | Description
--- | ---
see |
see |
access | private

### _size( String $filename, ) : Mixed

#### Description

Returns the file size, in bytes, or false, on failure
Determines the size without calling Net_SFTP::_realpath()

#### Arguments

Name | Type | Description | Default
--- | --- | --- | ---
$filename | String |  |

#### Return value

Type | Description
--- | ---
Mixed |

#### Tags

Name | Description
--- | ---
access | private

### _stat( String $filename, Integer $type, ) : Mixed

#### Description

Returns general information about a file or symbolic link
Determines information without calling Net_SFTP::_realpath(). The second parameter can be either NET_SFTP_STAT or NET_SFTP_LSTAT.

#### Arguments

Name | Type | Description | Default
--- | --- | --- | ---
$filename | String |  |
$type | Integer |  |

#### Return value

Type | Description
--- | ---
Mixed |

#### Tags

Name | Description
--- | ---
access | private

### chdir( String $dir, ) : Boolean

#### Description

Changes the current directory

#### Arguments

Name | Type | Description | Default
--- | --- | --- | ---
$dir | String |  |

#### Return value

Type | Description
--- | ---
Boolean |

#### Tags

Name | Description
--- | ---
access | public

### chmod( Integer $mode, String $filename, ) : Mixed

#### Description

Set permissions on a file.
Returns the new file permissions on success or FALSE on error.

#### Arguments

Name | Type | Description | Default
--- | --- | --- | ---
$mode | Integer |  |
$filename | String |  |

#### Return value

Type | Description
--- | ---
Mixed |

#### Tags

Name | Description
--- | ---
access | public

### delete( String $path, ) : Boolean

#### Description

Deletes a file on the SFTP server.

#### Arguments

Name | Type | Description | Default
--- | --- | --- | ---
$path | String |  |

#### Return value

Type | Description
--- | ---
Boolean |

#### Tags

Name | Description
--- | ---
access | public

### get( String $remote_file, $local_file = false, ) : Mixed

#### Description

Downloads a file from the SFTP server.
Returns a string containing the contents of $remote_file if $local_file is left undefined or a boolean false if the operation was unsuccessful. If $local_file is defined, returns true or false depending on the success of the operation

#### Arguments

Name | Type | Description | Default
--- | --- | --- | ---
$remote_file | String |  |
$local_file | n/a |  | false

#### Return value

Type | Description
--- | ---
Mixed |

#### Tags

Name | Description
--- | ---
access | public

### getLastSFTPError( ) : String

#### Description

Returns the last error

#### Return value

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

#### Tags

Name | Description
--- | ---
access | public

### getSFTPErrors( ) : String

#### Description

Returns all errors

#### Return value

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

#### Tags

Name | Description
--- | ---
access | public

### getSFTPLog( ) : String

#### Description

Returns a log of the packets that have been sent and received.
Returns a string if NET_SFTP_LOGGING == NET_SFTP_LOG_COMPLEX, an array if NET_SFTP_LOGGING == NET_SFTP_LOG_SIMPLE and false if !defined('NET_SFTP_LOGGING')

#### Return value

Type | Description
--- | ---
String | or Array

#### Tags

Name | Description
--- | ---
access | public

### getSupportedVersions( ) : Array

#### Description

Get supported SFTP versions

#### Return value

Type | Description
--- | ---
Array |

#### Tags

Name | Description
--- | ---
access | public

### login( String $username, $password = '', ) : Boolean

#### Description

Login

#### Arguments

Name | Type | Description | Default
--- | --- | --- | ---
$username | String |  |
$password | n/a |  | ''

#### Return value

Type | Description
--- | ---
Boolean |

#### Tags

Name | Description
--- | ---
access | public

### lstat( String $filename, ) : Mixed

#### Description

Returns general information about a file or symbolic link.
Returns an array on success and false otherwise.

#### Arguments

Name | Type | Description | Default
--- | --- | --- | ---
$filename | String |  |

#### Return value

Type | Description
--- | ---
Mixed |

#### Tags

Name | Description
--- | ---
access | public

### mkdir( String $dir, ) : Boolean

#### Description

Creates a directory.

#### Arguments

Name | Type | Description | Default
--- | --- | --- | ---
$dir | String |  |

#### Return value

Type | Description
--- | ---
Boolean |

#### Tags

Name | Description
--- | ---
access | public

### nlist( $dir = '.', ) : Mixed

#### Description

Returns a list of files in the given directory

#### Arguments

Name | Type | Description | Default
--- | --- | --- | ---
$dir | n/a |  | '.'

#### Return value

Type | Description
--- | ---
Mixed |

#### Tags

Name | Description
--- | ---
access | public

### pwd( ) : Mixed

#### Description

Returns the current directory name

#### Return value

Type | Description
--- | ---
Mixed |

#### Tags

Name | Description
--- | ---
access | public

### rawlist( $dir = '.', ) : Mixed

#### Description

Returns a detailed list of files in the given directory

#### Arguments

Name | Type | Description | Default
--- | --- | --- | ---
$dir | n/a |  | '.'

#### Return value

Type | Description
--- | ---
Mixed |

#### Tags

Name | Description
--- | ---
access | public

### rename( String $oldname, String $newname, ) : Boolean

#### Description

Renames a file or a directory on the SFTP server

#### Arguments

Name | Type | Description | Default
--- | --- | --- | ---
$oldname | String |  |
$newname | String |  |

#### Return value

Type | Description
--- | ---
Boolean |

#### Tags

Name | Description
--- | ---
access | public

### rmdir( String $dir, ) : Boolean

#### Description

Removes a directory.

#### Arguments

Name | Type | Description | Default
--- | --- | --- | ---
$dir | String |  |

#### Return value

Type | Description
--- | ---
Boolean |

#### Tags

Name | Description
--- | ---
access | public

### size( String $filename, ) : Mixed

#### Description

Returns the file size, in bytes, or false, on failure
Files larger than 4GB will show up as being exactly 4GB.

#### Arguments

Name | Type | Description | Default
--- | --- | --- | ---
$filename | String |  |

#### Return value

Type | Description
--- | ---
Mixed |

#### Tags

Name | Description
--- | ---
access | public

### stat( String $filename, ) : Mixed

#### Description

Returns general information about a file.
Returns an array on success and false otherwise.

#### Arguments

Name | Type | Description | Default
--- | --- | --- | ---
$filename | String |  |

#### Return value

Type | Description
--- | ---
Mixed |

#### Tags

Name | Description
--- | ---
access | public

#### Properties

$extensions, $fileType, $packet_buffer, $packet_log, $packet_type, $packet_type_log, $packet_types, $pwd, $request_id, $sftp_errors, $status_codes, $version,

### Array public $extensions = array()

Extensions supported by the server

### Integer public $fileType = 0

File Type

### String public $packet_buffer = ''

Packet Buffer

### Array public $packet_log = array()

Packet Log

### Integer public $packet_type = -1

The Packet Type
The request ID exists in the off chance that a packet is sent out-of-order. Of course, this library doesn't support concurrent actions, so it's somewhat academic, here.

### Array public $packet_type_log = array()

Packet Type Log

### Array public $packet_types = array()

Packet Types

### String public $pwd = false

Current working directory

### Integer public $request_id = false

The Request ID
The request ID exists in the off chance that a packet is sent out-of-order. Of course, this library doesn't support concurrent actions, so it's somewhat academic, here.

### String public $sftp_errors = array()

Error information

### Array public $status_codes = array()

Status Codes

### Integer public $version =

Server SFTP version
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).