stevebauman/winperm

Windows 文件/文件夹权限解析器。

该软件包的官方仓库似乎已消失,因此该软件包已被冻结。

安装: 922

依赖关系: 0

建议者: 0

安全: 0

星标: 1

关注者: 3

分支: 0

开放问题: 0

类型:项目

v2.0.2 2017-11-14 17:35 UTC

This package is auto-updated.

Last update: 2024-03-24 07:19:22 UTC


README

Scrutinizer Code Quality Latest Stable Version License

Windows 文件/文件夹权限解析器。

描述

WinPerm 允许您查看 Windows 操作系统上文件和文件夹的权限。

要求

  • PHP 5.5 或更高版本
  • exec() 权限
  • 访问 icacls 命令
  • Windows 主机服务器

安装

通过 composer 安装 WinPerm。将以下内容添加到您的 composer.json 依赖项中

"stevebauman/winperm": "2.0.*"

然后运行 composer update

用法

创建一个新的 Stevebauman\WinPerm\Scanner 实例,然后通过调用 setPath($path) 设置路径

检索账户

$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!
}

检索 ID

Windows 使用独特的标识符来标识文件和文件夹,即使它们被移动或修改,这些标识符也不会改变。

要检索此唯一 ID,请调用 getId() 方法

$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!
}

用法(网络驱动器)

要使用 WinPerm 与网络驱动器,只需在设置路径之前使用系统账户挂载驱动器即可

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();