如何共享具有特定用户 powershell Smbshare 完全访问权限的文件夹

时间:2021-03-07 17:30:27

标签: windows powershell share smb

<块引用>

如何与接收用户的 smbshare 共享文件夹 带 $ 的参数,在我的代码中文件夹的名称与 用户。我可以共享一个文件夹,对特定名称(如“管理员”)具有完全访问权限,但不能共享像 $username 这样的用户名。

import React, {useState, useEffect} from 'react';
import axios from 'axios';
import {Link} from 'react-router-dom';
import '../../static/Bookings.css';
import {BsFilterRight} from "react-icons/bs";

const Bookings= ()=>{
    const[Bookings, setBooking]=useState([]);
    const[searchByName, setSearchByName]=useState('');
    const[FilteredNames, setFilteredNames]=useState([]);
    const[searchByConsultant, setSearchByConsultant]=useState('');
    const[FilteredConsultants, setFilteredConsultants]=useState([]);

    useEffect(()=>{
        loadUsers();
    }, []);

    useEffect(()=>{
        setFilteredNames(
            Bookings.filter(Booking=>{
                return Booking.name.toLowerCase().includes(searchByName.toLowerCase())
            })
        )
    }, [searchByName, Bookings]);

    useEffect(()=>{
        setFilteredConsultants(
            Bookings.filter(Booking=>{
                return Booking.consultant.toLowerCase().includes(searchByConsultant.toLowerCase())
            })
        )
    }, [searchByConsultant, Bookings]);

    const loadUsers= async()=>{
        const result =await axios.get("http://localhost:3001/Bookings");
        setBooking(result.data.reverse());
    };

    const deleteUser=async id => {
        await axios.delete(`http://localhost:3001/Bookings/${id}`);
        loadUsers();
    }

    return(
        <div className="Booking-page-container">
            <h2 className="text-center mb-4">Bookings Page</h2>
            <table class="table table-bordered table-striped border shadow">
                <thead>
                    <tr>
                        <th scope="col"></th>
                        <th scope="col">
                        <BsFilterRight/>
                            <input 
                                placeholder="search by name..."
                                onChange={e=>setSearchByName(e.target.value)}
                            />  
                        </th>
                        <th scope="col">
                        <BsFilterRight/>
                            <input 
                                placeholder="search by consultant..."
                                onChange={e=>setSearchByConsultant(e.target.value)}
                            />
                        </th>
                        <th scope="col">Email</th>
                        <th>Action</th>
                    </tr>
                </thead>
          
                <thead class="thead-dark">
                    <tr>
                        <th scope="col"></th>
                        <th scope="col">Name</th>
                        <th scope="col">Consultant</th>
                        <th scope="col">Email</th>
                        <th>Action</th>
                    </tr>
                </thead>
                <tbody>
                    {FilteredNames.map((Booking,index)=>(
                        <tr>
                            <th scope="row">{index+1}</th>
                            <td>{Booking.name}</td>
                            <td>{Booking.consultant}</td>
                            <td>{Booking.email}</td>
                            <td>
                                <Link class="btn btn-primary mr-2" to={`/Bookings/view/${Booking.id}`}>View</Link>
                                <Link class="btn btn-outline-primary mr-2" to={`/Bookings/edit/${Booking.id}`}>Edit</Link>
                                <Link class="btn btn-danger" onClick={()=>deleteUser(Booking.id)}>Delete</Link>
                            </td>
                        </tr>   
                    ))}
                </tbody>
            </table>
        </div>
    );
};

export default Bookings;

1 个答案:

答案 0 :(得分:0)

不需要每个变量之间的引号,对于加入域的计算机,$username 应该采用 "DOMAIN\user" 格式,或者对于未加入域的计算机采用 "$env:ComputerName\user" 格式。如果共享已存在,您可以使用 Set-ACL 向新用户授予权限。