如何用ADSI接口实现网络文件夹共享权限的配置

thinp 2005-03-25 02:57:18
我用IADsFileShare接口实现了机器文件夹的共享,不过发现权限里面是everyone可读可写可修改,我想把every删除了,从里面加进一个组(可读),再加进一个用户,可写可修改,应如何做?
...全文
137 4 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
goodheartppl 2005-03-28
  • 打赏
  • 举报
回复
IADsFileShare Property Methods

The property methods of the IADsFileshare interface get or set the properties described in the following table. For more information, see Interface Property Methods.


Properties
Property Description
CurrentUserCount
[Visual Basic]
Access: Read-only
DataType: Long

[C++]
HRESULT get_CurrentUserCount
([out] LONG* plCurrentUserCount);

The number of users connected to the share.
Description
[Visual Basic]
Access: Read/Write
DataType: BSTR

[C++]
HRESULT get_Description
([out] BSTR* pbstrDescription);
HRESULT put_Description
([in] BSTR bstrDescription);

The description of the file share.
HostComputer
[Visual Basic]
Access: Read/Write
DataType: BSTR

[C++]
HRESULT get_HostComputer
([out] BSTR* pbstrHostComputer);
HRESULT put_HostComputer
([in] BSTR bstrHostComputer);

An ADsPath reference to the host computer.
MaxUserCount
[Visual Basic]
Access: Read-only
DataType: Long

[C++]
HRESULT get_MaxUserCount
([out] LONG* plMaxUserCount);

The maximum number of users allowed to access the share at one time.
Path
[Visual Basic]
Access: Read/Write
DataType: BSTR

[C++]
HRESULT get_Path
([out] BSTR* pbstrPath);
HRESULT put_Path
([in] BSTR bstrPath);

The file system path to the shared directory.

Example Code [Visual Basic]
To access the properties of file shares on a computer, you must first bind to the "LanmanServer" on the machine. The following code example shows how to set up the description and the maximum number of allowed users for all the public file shares on the computer, named as "myMachine", in the default domain.

Dim fs As IADsFileService
Dim share As IADsFileShare
On Error GoTo Cleanup

Set fs = GetObject("WinNT://myMachine/LanmanServer")
If (fs.class = "FileService") Then
For Each share In fs
share.description = share.name & " is my working folder."
share.MaxUserCount = 10
share.SetInfo
Next share
End if

Cleanup:
If (Err.Number<>0) Then
MsgBox("An error has occurred. " & Err.Number)
End If
Set fs = Nothing
Set share = Nothing
Example Code [Visual Basic]
The following code example shows how to make the existing C:\MyFolder directory a public file share.

Dim fs As IADsFileShare
Dim cont As IADsContainer
On Error GoTo Cleanup

Set cont = GetObject("WinNT://yourDomain/yourMachineName/LanmanServer")

Set fs = cont.Create("FileShare", "Public")
Debug.Print fs.Class
fs.Path = "C:\MyFolder"
fs.SetInfo

Cleanup:
If (Err.Number<>0) Then
MsgBox("An error has occurred. " & Err.Number)
End If
Set cont = Nothing
Set fs = Nothing
Example Code [C++]
The following code example makes the existing C:\MyFolder directory a public file share.

IADsFileShare *pShare = NULL;
IADsContainer *pCont = NULL;
LPWSTR adsPath = L"WinNT://yourMachineName/LanmanServer";
HRESULT hr = S_OK;

hr = ADsGetObject(adsPath, IID_IADsContainer,(void**)&pCont);
if(FAILED(hr)) {goto Cleanup;}

hr = pCont->Create(CComBSTR("FileShare"), CComBSTR("Public"), (IDispatch**)&pShare);

if(FAILED(hr)) {goto Cleanup;}

hr = pShare->put_Path(CComBSTR("c:\\public"));

if(FAILED(hr)) {goto Cleanup;}

hr = pShare->SetInfo();

Cleanup:
if(pCont) pCont->Release();
if(pShare) pShare->Release();
Requirements
Client: Requires Windows XP or Windows 2000 Professional.
Server: Requires Windows Server 2003 or Windows 2000 Server.
Redistributable: Requires Active Directory Client ExtensiononWindows NT 4.0,Windows 95,Windows 98andWindows Me.
Header: Declared in Iads.h.
Library: Included as a resource in Activeds.dll.
GUID: IID_IADsFileShare is defined as EB6DCAF0-4B83-11CF-A995-00AA006BC149.


See Also
thinp 2005-03-28
  • 打赏
  • 举报
回复
有人曾经做过吗?
thinp 2005-03-28
  • 打赏
  • 举报
回复
谢谢 goodheartppl(goodheart),这个只是建一个共享文件,我如何改变它的权限呢?比如给一个组添可读权限,给一个用户添可写权限

16,547

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • AIGC Browser
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧