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

thinp 2005-03-25 02:57:18
我用IADsFileShare接口实现了机器文件夹的共享,不过发现权限里面是everyone可读可写可修改,我想把every删除了,从里面加进一个组(可读),再加进一个用户,可写可修改,应如何做?
...全文
131 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),这个只是建一个共享文件,我如何改变它的权限呢?比如给一个组添可读权限,给一个用户添可写权限
原系统的局域网设置条目很多,对此不太熟悉的用户,可能搞得焦头烂额也未能搞定局域网互访。本系统特意编写了批处理,可以轻易地打开(或关闭)局域网互访。 本系统刚装好的时候,安全性是比较高的,单机拨号上网的用户,可得到最大程度的保护。此时局域网不通,不能被其它机访问。 多机上网的场合,局域网互访功能是必要的。多机上网一般是用路由器,此时电脑没有暴露在外网,常用的IPC$入侵方式对路由器无效。此时请运行“开通局域网共享”的批处理,一招解决问题。 如果您想学习一下局域网互访究竟需要修改哪里,请阅下文。 局域网互访第一关卡: 操作系统默认:利用ipc$通道可以建立空连接,匿名枚举出该机有多少帐户。显然有一定的安全隐患。黑客可以利用扫描器,找到开放IPC$共享的电脑,匿名枚举出该机的所有用户帐号,如果用户的帐号不设密码,则容易被入侵。本系统已禁止空连接。这样,即使用户没设密码,上网也不会有多大的风险。但影响到局域网互访。 局域网互访第二关卡: 本地安全策略--安全选项--帐户:使用空白密码的本地帐户只允许进行控制台登录。系统默认值是:已启用。 解说:很多人的帐户并没有加密码。这样,当局域网中别的电脑访问本机时,会弹出错误提示:登录失败:用户帐户限制………。这是XP系统的一条安全策略造成的,防止别人趁你空密码时进入你的电脑。如果你的电脑是家用的,没必要设密码,那就应把它设为:已停用。 局域网互访第三关卡: 控制面板--防火墙--例外--文件和打印机共享。系统默认:不选。 解说:所有的策略都设置好了,局域网依然不能访问,提示:您没有权限使用网络资源,找不到网络路径!呵呵,真是令人大为光火。这是因为XP还有一道关卡,就是防火墙,必须要经过防火墙的允许才行。 知识普及:IPC$入侵是黑客惯用的手段。IPC$漏洞不能穿越路由器,所以用路由器上网的用户不必担心开放了局域网共享会有什么隐患。但要注意:路由器会被人扫描并窃取保存在里面的ADSL帐号密码。所以也不要大意,赶快把路由器默认的用户名和密码改掉。 ※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※ 补 充 声 明 最近网上有文章说某些系统有“漏洞”,其中提到本系统。理由是系统内的“开通局域网互访”的批处理是一颗“地雷”。于是有部分似懂非懂的网友跟着起哄。 作者对此声明一下: 其一、本系统也提供了“关闭局域网共享”的批处理,只谈彼而不谈此,是不公允的。本系统已考虑得非常到位,没有只能开不能关的事。 其二、开通局域网互访后,也没事。因为局域网是以路由器(或网关电脑)作为出口的,利用IPC$的入侵方式,无法通过路由器(或网关电脑)。所以说开了互访就有“隐患”是不对的。只有在单机拨号上网时,该功能才会有隐患。因此,请您记着单机时关闭它就可以了。 特此声明。

16,548

社区成员

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

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

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