File_SMBPasswd
[ class tree: File_SMBPasswd ] [ index: File_SMBPasswd ] [ all elements ]

Class: File_SMBPasswd

Source Location: /File_SMBPasswd-1.0.3/SMBPasswd.php

Class Overview

PEAR
   |
   --File_SMBPasswd

Class to manage SAMBA smbpasswd-style files


Author(s):

Version:

  • 0.9.0

Variables

Methods


Inherited Variables

Inherited Methods


Class Details

[line 75]
Class to manage SAMBA smbpasswd-style files

Example 1 (modifying existing file):

$f = new File_SMBPasswd('./smbpasswd'); $f->load(); $f->addAccount('sepp3', 12, 'MyPw'); $f->modAccount('sepp', '', 'MyPw'); $f->delAccount('karli'); $f->printAccounts(); $f->save();

Example 2 (creating a new file):

$f = new File_SMBPasswd('./smbpasswdnew'); $f->addAccount('sepp1', 12, 'MyPw'); $f->addAccount('sepp3', 1000, 'MyPw'); $f->save();

Example 3 (authentication):

$f = new File_SMBPasswd('./smbpasswdnew'); $f->load(); if ($f->verifyAccount('sepp', 'MyPw')) { echo "Account valid"; } else { echo "Account invalid or disabled"; }

  • Author: Michael Bretterklieber <mbretter@jawa.at>
  • Version: 0.9.0
  • Access: public


[ Top ]


Class Variables

$accounts = array()

[line 81]

Multidimensional array of accounts

Type:   array


[ Top ]

$cryptEngine =

[line 93]

Class who generates the NT-Hash and LAN-Manager-Hash

Type:   object


[ Top ]

$file =

[line 87]

Path to the smbpasswd file

Type:   string


[ Top ]

$fplock =

[line 99]

Filehandle, of locked File

Type:   resource


[ Top ]



Method Detail

File_SMBPasswd (Constructor)   [line 108]

object File_SMBPasswd File_SMBPasswd( [string $file = 'smbpasswd'])

Constructor
  • Access: public

Parameters:

string   $file   — 

[ Top ]

addAccount   [line 216]

mixed addAccount( $user $user, $userid $userid, $pass $pass, [$comment $comment = ''], [$flags $flags = '[U ]'])

Adds an account
  • Return: returns PEAR_Error, if the user already exists
  • Access: public

Parameters:

$user   $user   —  new username
$userid   $userid   —  new userid
$pass   $pass   —  Plaintext password
$comment   $comment   —  Comment
$flags   $flags   —  Account-flags (see man 5 smbpasswd)

[ Top ]

addAccountEncrypted   [line 183]

mixed addAccountEncrypted( $user $user, $userid $userid, [$lmhash $lmhash = ''], [$nthash $nthash = ''], [$comment $comment = ''], [$flags $flags = '[U ]'])

Adds an account, with pre-encrypted passwords
  • Return: returns PEAR_Error, if the user already exists
  • Access: public

Parameters:

$user   $user   —  new username
$userid   $userid   —  new userid
$lmhash   $lmhash   —  LAN-Manager-Hash
$nthash   $nthash   —  NT-Hash
$comment   $comment   —  Comment
$flags   $flags   —  Account-flags (see man 5 smbpasswd)

[ Top ]

addMachine   [line 258]

mixed addMachine( $machine $machine, $userid $userid, [$comment $comment = ''])

Adds a machine-account
  • Return: returns PEAR_Error, if the user already exists
  • Access: public

Parameters:

$machine   $machine   —  new username
$userid   $userid   —  new userid
$comment   $comment   —  Comment

[ Top ]

addUser   [line 243]

mixed addUser( $user $user, $userid $userid, $pass $pass, [$comment $comment = ''])

Adds a user-account
  • Return: returns PEAR_Error, if the user already exists
  • Access: public

Parameters:

$user   $user   —  new username
$userid   $userid   —  new userid
$pass   $pass   —  Plaintext password
$comment   $comment   —  Comment

[ Top ]

delAccount   [line 346]

mixed delAccount( $user $name)

Deletes an account
  • Return: returns PEAR_Error, if the user doesn't exists
  • Access: public

Parameters:

$user   $name   —  username

[ Top ]

delUser   [line 361]

void delUser( $user)

This is an alias for delAccount
  • See: File_SMBPasswd::delAccount

Parameters:

   $user   — 

[ Top ]

getAccounts   [line 166]

array &getAccounts( )

Get the value of accounts property
  • Access: public

[ Top ]

getFile   [line 156]

string getFile( )

Get the value of file property
  • Access: public

[ Top ]

load   [line 120]

mixed load( )

Load the given smbpasswd file
  • Return: true on success, PEAR_Error on failure
  • Access: public

[ Top ]

lock   [line 419]

mixed lock( )

Locks the given file
  • Return: PEAR_Error, true on succes
  • Access: public

[ Top ]

modAccount   [line 313]

mixed modAccount( $user $user, [$userid $userid = ''], [$pass $pass = ''], [$comment $comment = ''], [$flags $flags = ''])

Modifies an account with given plaintext password
  • Return: returns PEAR_Error, if the user doesen't exists
  • Access: public

Parameters:

$user   $user   —  new username
$userid   $userid   —  new userid
$pass   $pass   —  Plaintext password
$comment   $comment   —  Comment
$flags   $flags   —  Account-flags (see man 5 smbpasswd)

[ Top ]

modAccountEncrypted   [line 276]

mixed modAccountEncrypted( $user $user, [$userid $userid = ''], [$lmhash $lmhash = ''], [$nthash $nthash = ''], [$comment $comment = ''], [$flags $flags = ''])

Modifies an account with the pre-encrypted Hashes
  • Return: returns PEAR_Error, if the user doesen't exists
  • Access: public

Parameters:

$user   $user   —  new username
$userid   $userid   —  new userid
$lmhash   $lmhash   —  LAN-Manager-Hash
$nthash   $nthash   —  NT-Hash
$comment   $comment   —  Comment
$flags   $flags   —  Account-flags (see man 5 smbpasswd)

[ Top ]

modUser   [line 333]

void modUser( $user, [ $userid = ''], [ $pass = ''], [ $comment = ''], [ $flags = ''])

This is an alias for modAccount
  • See: File_SMBPasswd::modAccount

Parameters:

   $user   — 
   $userid   — 
   $pass   — 
   $comment   — 
   $flags   — 

[ Top ]

printAccounts   [line 495]

void printAccounts( )

Print all accounts from smbpasswd file
  • Access: public

[ Top ]

save   [line 462]

mixed save( [$file $file = ''])

Writes changes to smbpasswd file and locks, unlocks and closes it
  • Return: returns PEAR_Error, if the file is not writeable
  • Access: public

Parameters:

$file   $file   —  Filename

[ Top ]

unlock   [line 443]

mixed unlock( )

Unlocks the given file
  • Return: PEAR_Error, true on succes
  • Access: public

[ Top ]

verifyAccount   [line 405]

boolean verifyAccount( $user $user, $pass $pass)

Verifies an account with the given plaintext password
  • Return: true if password is ok
  • Access: public

Parameters:

$user   $user   —  username
$pass   $pass   —  The plaintext password

[ Top ]

verifyAccountEncrypted   [line 378]

boolean verifyAccountEncrypted( $user $user, $nthash $nthash, [$lmhash $lmhash = ''])

Verifies a user's password Prefer NT-Hash instead of weak LAN-Manager-Hash
  • Return: true if password is ok
  • Access: public

Parameters:

$user   $user   —  username
$nthash   $nthash   —  NT-Hash in hex
$lmhash   $lmhash   —  LAN-Manager-Hash in hex

[ Top ]


Documentation generated on Mon, 11 Mar 2019 15:28:55 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.