承接 stevebauman/winperm 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

stevebauman/winperm

最新稳定版本:v2.0.2

Composer 安装命令:

composer create-project stevebauman/winperm

包简介

A Windows File / Folder Permission Parser.

README 文档

README

Scrutinizer Code Quality Latest Stable Version License

A Windows File / Folder Permission Parser.

Description

WinPerm allows you to view the permissions on files and folders on the Windows OS.

Requirements

  • PHP 5.5 or greater
  • exec() permissions
  • Access to the icacls command
  • A Windows hosted server

Installation

Install WinPerm through composer. Insert this into your composer.json dependencies:

"stevebauman/winperm": "2.0.*"

Then run composer update.

Usage

Create a new Stevebauman\WinPerm\Scanner instance, and then set the path by calling setPath($path):

Retrieving Accounts

$scanner = new \Stevebauman\WinPerm\Scanner();

try {
    $path = 'C:\\Windows\System32';
    
    $scanner->setPath($path);
    
    $accounts = $scanner->getAccounts();
    
    foreach ($accounts as $account) {
        // Returns the accounts name, ex: 'BUILTIN\Administrators'
        echo $account->getName();
        
        // Get the accounts permissions.
        $permissions = $account->getPermissions();
        
        foreach ($permissions as $permission) {
            // Returns the ACE definition of the permission, ex: 'F'
            echo $permission->getDefinition();
            
            // Echo the object to retrieve the full name, ex: 'Full Access'
            echo $permission;
        }
    }
    
} catch (\Stevebauman\WinPerm\Exceptions\InvalidPathException $e) {
    // Uh oh, it looks like the path doesn't exist!
}

Retrieving ID

Windows utilizes unique identifiers for files and folders that does not change when it is moved or modified.

To retrieve this unique ID, call the getId() method:

$scanner = new \Stevebauman\WinPerm\Scanner();

try {
    $path = 'C:\\Windows\System32';
    
    $scanner->setPath($path);
    
    echo $scanner->getId(); // Returns '0x0000000000000000001200000001b1t7'
} catch (\Stevebauman\WinPerm\Exceptions\InvalidPathException $e) {
    // Uh oh, it looks like the path doesn't exist!
}

Usage (Network Drive)

To use WinPerm with a network drive, simply mount the drive with a system account before setting your path:

use Stevebauman\WinPerm\Scanner;

$drive = 'Z';
$path = '\\\\server\\folder';
$username = 'ACME\\administrator';
$password = 'Password1';

$command = sprintf('net use %s: %s %s /user:%s /persistent:no', $drive, $path, $password, $username);

exec($command);

$scanner = new Scanner('Z:\\HR');

$accounts = $scanner->getAccounts();

统计信息

  • 总下载量: 922
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 3
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-10-30