找到文件夹的所有者 [英] Find the Owner of a folder

查看:69
本文介绍了找到文件夹的所有者的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



有没有办法可以使用vb.net找到文件夹的所有者?我知道怎么用
找到权限,但我不知道如何找到主人。

谢谢

SimeonD

推荐答案

" SimeonD" < si ***** @nospam.nospamschrieb
"SimeonD" <si*****@nospam.nospamschrieb



有没有办法可以找到文件夹的所有者,使用vb.net?我知道

如何找到权限,但我不知道如何找到

的所有者。

谢谢

SimeonD
Hi
Is there a way I can fnd the Owner of a folder, using vb.net? I know
how to find the permissions, but I can''t figure how to find the
owner.
Thanks
SimeonD



1.创建DirectoryInfo对象

2.调用它的GetAccessControl方法。它返回一个DirectorySecurity

对象。

3.调用返回对象的GetOwner方法。这样的事情:


Dim sidType As Type =

GetType(System.Security.Principal.SecurityIdentifi er)

Dim owner As System.Security.Principal.SecurityIdentifier


owner = DirectCast(DS.GetOwner(sidType),

Security.Principal.SecurityIdentifier)


(DS是DirectorySecurity对象)


4.所有者是所有者。 :)

AZ

1. Create a DirectoryInfo object
2. Call it''s GetAccessControl method. It returns a DirectorySecurity
object.
3. Call the GetOwner method of the returned object. Something like this:

Dim sidType As Type =
GetType(System.Security.Principal.SecurityIdentifi er)
Dim owner As System.Security.Principal.SecurityIdentifier

owner = DirectCast(DS.GetOwner(sidType),
Security.Principal.SecurityIdentifier)

(DS is the DirectorySecurity object)

4. Owner is the owner. :)
AZ


感谢AZ的回复!


Hi Simeon ,


正如AZ建议的那样,我们可以先通过调用

DirectoryInfo.GetAccessControl方法获取DirectorySecurity对象,然后通过
$获取所有者b $ b调用DirectorySecurity.GetOwner方法传递NTAccount作为

参数。


以下是一个示例:


Imports System.IO

Imports System.Security.AccessControl

Imports System.Security.Principal


Private Sub Form1_Load (ByVal sender As System.Object,ByVal e As

System.EventArgs)处理MyBase.Load

Dim di As New DirectoryInfo(" directoryname")

Dim ds As DirectorySecurity = di.GetAccessControl()

Dim owner As NTAccount = CType(ds.GetOwner(GetType(NTAccount)),

NTAccount)< br $>
End Sub


希望这会有所帮助。

如果你有一个ny问题,请随时告诉我。


此致,

Linda Liu

Microsoft在线社区支持

让客户满意是我们的首要任务。我们欢迎您的意见和

有关我们如何改进我们为您提供的支持的建议。请

随时让我的经理知道您对服务水平的看法

提供。您可以直接向我的经理发送反馈:
ms****@microsoft.com


========================================== ========

通过电子邮件收到我的帖子通知?请参阅
http://msdn.microsoft .com / subscripti ... ult.aspx#notif

ications。


注意:MSDN托管新闻组支持服务是针对非紧急问题

如果社区或微软支持人员在1个工作日内做出初步回复是可以接受的。请注意,每个跟随

的响应可能需要大约2个工作日作为支持

专业人士与您合作可能需要进一步调查才能达到

最有效的分辨率。该产品不适用于需要紧急,实时或基于电话的交互或复杂的b $ b项目分析和转储分析问题的情况。这种性质的问题最好通过联系

Microsoft客户支持服务(CSS)处理
href =http://msdn.microsoft.com/subscriptions/support/default.aspx\"target =_ blank> http://msdn.microsoft.com/subscripti...t/default.aspx

======================================== ==========

此帖子按原样提供。没有保证,也没有授予任何权利。
Thanks AZ for your reply!

Hi Simeon,

As AZ has suggested, we can get the DirectorySecurity object by calling
DirectoryInfo.GetAccessControl method first and then get the owner by
calling the DirectorySecurity.GetOwner method passing NTAccount as the
parameter.

The following is a sample:

Imports System.IO
Imports System.Security.AccessControl
Imports System.Security.Principal

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim di As New DirectoryInfo("directoryname")
Dim ds As DirectorySecurity = di.GetAccessControl()
Dim owner As NTAccount = CType(ds.GetOwner(GetType(NTAccount)),
NTAccount)
End Sub

Hope this helps.
If you have any question, please feel free to let me know.

Sincerely,
Linda Liu
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsoft.com.

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.


5月12日上午8:04,vl ... @ online.microsoft.com(Linda Liu [MSFT])

写道:
On May 12, 8:04 am, v-l...@online.microsoft.com (Linda Liu[MSFT])
wrote:

感谢AZ的回复!


西默,

正如AZ建议的那样,我们可以先通过调用

DirectoryInfo.GetAccessControl方法获取DirectorySecurity对象,然后通过

调用获取所有者将NTAccount作为

参数传递的DirectorySecurity.GetOwner方法。


以下是一个示例:


进口System.IO

Imports System.Security.AccessControl

Imports System.Security.Principal


Private Sub Form1_Load(ByVal sender As System.Object,ByVal e As

System.EventArgs)处理MyBase.Load

Dim di As New DirectoryInfo(" directoryname")

Dim ds As DirectorySecurity = di.GetAccessControl()

Dim owner As NTAccount = CType(ds.GetOwner(GetType(NTAccount)),

NTAccount)

End Sub


希望这有帮助。

如果您有任何疑问,请随时告诉我。


此致,

琳达刘

Microsoft在线社区支持


让客户满意是我们的首要任务。我们欢迎您的意见和

有关我们如何改进我们为您提供的支持的建议。请

随时让我的经理知道您对服务水平的看法

提供。您可以直接向我的经理发送反馈:

msd ... @ microsoft.com。


=========== =======================================

获取通知我的帖子通过邮件?请参考http://msdn.microsoft.com/subscriptions/managednewsgroups/default.asp ...

ications。


注意:MSDN管理新闻组支持提供非紧急问题

,可以在1个工作日内收到社区或Microsoft支持工程师的初步回复。请注意,每个跟随

的响应可能需要大约2个工作日作为支持

专业人士与您合作可能需要进一步调查才能达到

最有效的分辨率。该产品不适用于需要紧急,实时或基于电话的交互或复杂的b $ b项目分析和转储分析问题的情况。这种性质的问题最好通过联系

微软客户支持服务(CSS)来处理,并与专门的微软支持工程师合作处理这些问题:http://msdn.microsoft.com/subscriptions /support/default.aspx。

=================================== ===============

此帖子按原样提供。没有保证,也没有赋予权利..
Thanks AZ for your reply!

Hi Simeon,

As AZ has suggested, we can get the DirectorySecurity object by calling
DirectoryInfo.GetAccessControl method first and then get the owner by
calling the DirectorySecurity.GetOwner method passing NTAccount as the
parameter.

The following is a sample:

Imports System.IO
Imports System.Security.AccessControl
Imports System.Security.Principal

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim di As New DirectoryInfo("directoryname")
Dim ds As DirectorySecurity = di.GetAccessControl()
Dim owner As NTAccount = CType(ds.GetOwner(GetType(NTAccount)),
NTAccount)
End Sub

Hope this helps.
If you have any question, please feel free to let me know.

Sincerely,
Linda Liu
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
msd...@microsoft.com.

==================================================
Get notification to my posts through email? Please refer tohttp://msdn.microsoft.com/subscriptions/managednewsgroups/default.asp...
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) athttp://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights..





为了缩短语法,我的命名空间也可以使用:

Dim owner As NTAccount = _ My.Computer.FileSystem.GetDirectoryInfo(" c:

\ resized")。GetAccessControl.GetOwner( GetType(NTAcc))


谢谢,


OnurGüzel

Hi,
To make syntax shorter, "my" namespace can also be used:
Dim owner As NTAccount = _ My.Computer.FileSystem.GetDirectoryInfo("c:
\resized").GetAccessControl.GetOwner(GetType(NTAcc ount))

Thanks,

Onur Güzel


这篇关于找到文件夹的所有者的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆