Class File_Passwd_Smb

Description

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 }

Located in Program_Root/Passwd/Smb.php (line 78)

File_Passwd_Common
   |
   --File_Passwd_Smb
Variable Summary
 object $msc
Method Summary
 File_Passwd_Smb File_Passwd_Smb ([string $file = 'smbpasswd'])
 mixed addUser (string $user, string $pass, array $params, [boolean $isMachine = false])
 mixed changePasswd (string $user, string $pass)
 mixed modUser (string $user, array $params)
 mixed parse ()
 mixed save ()
 mixed verifyEncryptedPasswd (string $user, string $nthash, [string $lmhash = ''])
 mixed verifyPasswd (string $user, string $pass)
 void __construct ([string $file = 'smbpasswd'])
Variables
object $msc (line 86)

Object which generates the NT-Hash and LAN-Manager-Hash passwds

  • access: protected

Inherited Variables

Inherited from File_Passwd_Common

File_Passwd_Common::$_contents
File_Passwd_Common::$_file
File_Passwd_Common::$_users
Methods
Constructor File_Passwd_Smb (line 94)

Constructor

  • access: public
File_Passwd_Smb File_Passwd_Smb ([string $file = 'smbpasswd'])
  • string $file: SMB passwd file
addUser (line 159)

Add a user

Returns a PEAR_Error if the user already exists

  • return: true on success or PEAR_Error
  • access: public
  • throws: PEAR_Error
mixed addUser (string $user, string $pass, array $params, [boolean $isMachine = false])
  • string $user: the user to add
  • string $pass: the new plaintext password
  • array $params: additional properties of user
    • userid
    • flags
    • lct
    • comment
  • boolean $isMachine: whether to add an machine account
changePasswd (line 219)

Change the passwd of a certain user

Returns a PEAR_Error if $user doesn't exist.

  • return: true on success or PEAR_Error
  • access: public
  • throws: PEAR_Error
mixed changePasswd (string $user, string $pass)
  • string $user: the user whose passwd should be changed
  • string $pass: the new plaintext passwd
modUser (line 194)

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
  • access: public
  • throws: PEAR_Error
mixed modUser (string $user, array $params)
  • string $user: the user to modify
  • array $params: an associative array of properties to change
parse (line 119)

Parse smbpasswd file

Returns a PEAR_Error if passwd file has invalid format.

  • return: true on success or PEAR_Error
  • access: public
mixed parse ()

Redefinition of:
File_Passwd_Common::parse()
Parse the content of the file
save (line 304)

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
  • access: public
  • throws: PEAR_Error
mixed save ()

Redefinition of:
File_Passwd_Common::save()
Apply changes and rewrite passwd file
verifyEncryptedPasswd (line 245)

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
mixed verifyEncryptedPasswd (string $user, string $nthash, [string $lmhash = ''])
  • string $user: username
  • string $nthash: NT-Hash in hex
  • string $lmhash: LAN-Manager-Hash in hex
verifyPasswd (line 284)

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
  • access: public
  • throws: PEAR_Error
mixed verifyPasswd (string $user, string $pass)
  • string $user: username
  • string $pass: the plaintext password
__construct (line 106)

Constructor (ZE2)

Rewritten because we want to init our crypt engine.

  • access: public
void __construct ([string $file = 'smbpasswd'])
  • string $file: SMB passwd file

Redefinition of:
File_Passwd_Common::__construct()
Constructor (ZE2)

Inherited Methods

Inherited From File_Passwd_Common

File_Passwd_Common::delUser()
File_Passwd_Common::getFile()
File_Passwd_Common::listUser()
File_Passwd_Common::load()
File_Passwd_Common::parse()
File_Passwd_Common::save()
File_Passwd_Common::setFile()
File_Passwd_Common::userExists()
File_Passwd_Common::_close()
File_Passwd_Common::_open()
File_Passwd_Common::_save()
File_Passwd_Common::__clone()
File_Passwd_Common::__construct()

Documention generated on Sat, 20 Sep 2003 16:14:43 +0200 by phpDocumentor 1.2.1