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

Class: File_Passwd_Smb

Source Location: /File_Passwd-1.1.7/Passwd/Smb.php

Class Overview

File_Passwd_Common
   |
   --File_Passwd_Smb

Manipulate SMB server passwd files.


Author(s):

Version:

  • $Revision: 1.18 $

Variables

Methods


Inherited Variables

Inherited Methods

Class: File_Passwd_Common

File_Passwd_Common::__construct()
Constructor (ZE2)
File_Passwd_Common::delUser()
Delete a certain user
File_Passwd_Common::getFile()
Get path of passwd file
File_Passwd_Common::listUser()
List user
File_Passwd_Common::load()
Loads the file
File_Passwd_Common::parse()
Parse the content of the file
File_Passwd_Common::save()
Apply changes and rewrite passwd file
File_Passwd_Common::setFile()
Set path to passwd file
File_Passwd_Common::userExists()
Check if a certain user already exists
File_Passwd_Common::_auth()
Base method for File_Passwd::staticAuth()
File_Passwd_Common::_close()
Closes a prior opened and locked file handle
File_Passwd_Common::_open()
Opens a file, locks it exclusively and returns the filehandle
File_Passwd_Common::_save()
Save the modified content to the passwd file

Class Details

[line 79]
Manipulate SMB server passwd files.

  • Usage Example 1 (modifying existing file):
    1.  $f &File_Passwd::factory('SMB');
    2.  $f->setFile('./smbpasswd');
    3.  $f->load();
    4.  $f->addUser('sepp3''MyPw'array('userid' => 12));
    5.  $f->changePasswd('sepp''MyPw');
    6.  $f->delUser('karli');
    7.  foreach($f->listUser(as $user => $data{
    8.    echo $user ':' implode(':'$data."\n";
    9.  }
    10.  $f->save();
  • Usage Example 2 (creating a new file):
    1.  $f &File_Passwd::factory('SMB');
    2.  $f->setFile('./smbpasswd');
    3.  $f->addUser('sepp1''MyPw'array('userid'=> 12));
    4.  $f->addUser('sepp3''MyPw'array('userid' => 1000));
    5.  $f->save();
  • Usage Example 3 (authentication):
    1.  $f &File_Passwd::factory('SMB');
    2.  $f->setFile('./smbpasswd');
    3.  $f->load();
    4.  if (true === $f->verifyPasswd('sepp''MyPw')) {
    5.      echo "User valid";
    6.  else {
    7.      echo "User invalid or disabled";
    8.  }



[ Top ]


Class Variables

$msc =

[line 87]

Object which generates the NT-Hash and LAN-Manager-Hash passwds
  • Access: protected

Type:   object


[ Top ]



Method Detail

__construct (Constructor)   [line 108]

File_Passwd_Smb __construct( [string $file = 'smbpasswd'])

Constructor (ZE2)

Rewritten because we want to init our crypt engine.

  • Access: public

Overrides File_Passwd_Common::__construct() (Constructor (ZE2))

Parameters:

string   $file     SMB passwd file

[ Top ]

File_Passwd_Smb (Constructor)   [line 95]

File_Passwd_Smb File_Passwd_Smb( [string $file = 'smbpasswd'])

Constructor
  • Access: public

Parameters:

string   $file     SMB passwd file

[ Top ]

addUser   [line 212]

mixed addUser( string $user, string $pass, array $params, [boolean $isMachine = false])

Add a user

Returns a PEAR_Error if:

  • user already exists
  • user contains illegal characters

  • Return: true on success or PEAR_Error
  • Throws: PEAR_Error
  • Access: public

Parameters:

string   $user     the user to add
string   $pass     the new plaintext password
array   $params     additional properties of user
  • userid
  • comment
boolean   $isMachine     whether to add an machine account

[ Top ]

changePasswd   [line 296]

mixed changePasswd( string $user, string $pass)

Change the passwd of a certain user

Returns a PEAR_Error if $user doesn't exist.

  • Return: true on success or PEAR_Error
  • Throws: PEAR_Error
  • Access: public

Parameters:

string   $user     the user whose passwd should be changed
string   $pass     the new plaintext passwd

[ Top ]

generatePasswd   [line 408]

string generatePasswd( string $pass, [string $mode = 'nt'])

Generate Password
  • Return: The crypted password.
  • Access: public

Parameters:

string   $pass     The plaintext password.
string   $mode     The encryption mode to use (nt|lm).

[ Top ]

modUser   [line 257]

mixed modUser( string $user, array $params)

Modify a certain user

You should not modify the password with this method unless it is already encrypted as nthash and lmhash!

Returns a PEAR_Error if:

  • user doesn't exist
  • an invalid property was supplied

  • Return: true on success or PEAR_Error
  • Throws: PEAR_Error
  • Access: public

Parameters:

string   $user     the user to modify
array   $params     an associative array of properties to change

[ Top ]

parse   [line 168]

mixed parse( )

Parse smbpasswd file

Returns a PEAR_Error if passwd file has invalid format.

  • Return: true on success or PEAR_Error
  • Access: public

Overrides File_Passwd_Common::parse() (Parse the content of the file)
[ Top ]

save   [line 384]

mixed save( )

Apply changes and rewrite CVS passwd file

Returns a PEAR_Error if:

  • directory in which the file should reside couldn't be created
  • file couldn't be opened in write mode
  • file couldn't be locked exclusively
  • file couldn't be unlocked
  • file couldn't be closed

  • Return: true on success or PEAR_Error
  • Throws: PEAR_Error
  • Access: public

Overrides File_Passwd_Common::save() (Apply changes and rewrite passwd file)
[ Top ]

staticAuth   [line 133]

mixed staticAuth( string $file, string $user, string $pass, [string $nt_or_lm = 'nt'])

Fast authentication of a certain user

Returns a PEAR_Error if:

  • file doesn't exist
  • file couldn't be opened in read mode
  • file couldn't be locked exclusively
  • file couldn't be unlocked (only if auth fails)
  • file couldn't be closed (only if auth fails)
  • invalid encryption method $nt_or_lm was provided

  • Return: true if authenticated, false if not or PEAR_Error
  • Access: public

Parameters:

string   $file     path to passwd file
string   $user     user to authenticate
string   $pass     plaintext password
string   $nt_or_lm     encryption mode to use (NT or LM hash)

[ Top ]

verifyEncryptedPasswd   [line 330]

mixed verifyEncryptedPasswd( string $user, string $nthash, [string $lmhash = ''])

Verifies a user's password

Prefer NT-Hash instead of weak LAN-Manager-Hash

Returns a PEAR_Error if:

  • user doesn't exist
  • user is disabled

  • Return: true if passwds equal, false if they don't or PEAR_Error
  • Access: public

Parameters:

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

[ Top ]

verifyPasswd   [line 363]

mixed verifyPasswd( string $user, string $pass)

Verifies an account with the given plaintext password

Returns a PEAR_Error if:

  • user doesn't exist
  • user is disabled

  • Return: true if passwds equal, false if they don't or PEAR_Error
  • Throws: PEAR_Error
  • Access: public

Parameters:

string   $user     username
string   $pass     the plaintext password

[ Top ]


Documentation generated on Sun, 04 Jan 2009 13:00:10 -0500 by phpDocumentor 1.4.0. PEAR Logo Copyright © PHP Group 2004.