本文介绍了如何获取特定用户的目录高级权限?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何获取特定用户的目录高级权限?
FullControl
Traverse
ReadData
ReadAttributes
ReadExtendedAttributes
CreateFiles
CreateDirectories
WriteAttributes
WriteExtendedAttributes
DeleteSubdirectoriesAndFiles
删除
ReadPermissions
ChangePermissions
TakeOwnership
谢谢。
我尝试过:
更新后的代码(应用解决方案)
Dim hasAccess As Boolean = False
Dim acc As NTAccount = New NTAccount(lblPrincipal.Text)
Dim secId As SecurityIdentifier = TryCast(acc.Translate(GetType(SecurityIdentifier)),SecurityIdentifier)
Dim dirSec As DirectorySecurity = Directory.GetAccessControl(lblFolderPath.Text)
Dim authRules As AuthorizationRuleCollection = dirSec。 GetAccessRules(True,True,GetType(SecurityIdentifier))
For each ar As FileSystemAccessRule in authRules
if secId.CompareTo(TryCast(ar.IdentityReference,SecurityIdentifier))= 0 Then
Dim fileSystemRights = ar.FileSystemRights
Console.WriteLine(fileSystemRights)
如果fileSystemRights.HasFlag(FileSystemRights.FullControl)那么
chkFull.Checked = True
结束如果
如果fileSystemRights.HasFlag (FileSystemRights.Traverse)然后
chkTraverse.Checked = True
结束如果
如果fileSystemRights.HasFlag(FileSystemRights.ReadData)那么
chkReadData.Checked = True
结束If
如果fileSystemRights.HasFlag(FileSystemRights.ReadAttributes)那么
chkReadAttributes.Checked = True
结束如果
如果fileSystemRights.HasFlag(FileSystemRi) ghts.ReadExtendedAttributes)然后
chkReadExtendedAttributes.Checked = True
结束如果
如果fileSystemRights.HasFlag(FileSystemRights.CreateFiles)那么
chkCreateFiles.Checked = True
结束如果
如果fileSystemRights.HasFlag(FileSystemRights.CreateDirectories)则
chkCreateFolders.Checked = True
结束如果
如果fileSystemRights.HasFlag(FileSystemRights.WriteAttributes)那么
chkWriteAttributes.Checked =真
结束如果
如果fileSystemRights.HasFlag(FileSystemRights.WriteExtendedAttributes)那么
chkWriteExtendedAttributes.Checked = True
结束如果
如果fileSystemRights.HasFlag(FileSystemRights.DeleteSubdirectoriesAndFiles)那么
chkDeleteSubfolders.Checked = True
结束如果
如果fileS ystemRights.HasFlag(FileSystemRights.Delete)然后
chkDelete.Checked = True
结束如果
如果fileSystemRights.HasFlag(FileSystemRights.ReadPermissions)那么
chkReadPermission.Checked = True
结束如果
如果fileSystemRights.HasFlag(FileSystemRights.ChangePermissions)那么
chkChangePermission.Checked = True
结束如果
如果fileSystemRights.HasFlag(FileSystemRights.TakeOwnership)那么
chkTakeOwnership.Checked = True
结束如果
结束如果
下一个
解决方案
How can get the Directory advanced permission for specific user?
FullControl
Traverse
ReadData
ReadAttributes
ReadExtendedAttributes
CreateFiles
CreateDirectories
WriteAttributes
WriteExtendedAttributes
DeleteSubdirectoriesAndFiles
Delete
ReadPermissions
ChangePermissions
TakeOwnership
Thank you.
What I have tried:
That's Code after Updated(Applied the solution)
Dim hasAccess As Boolean = False Dim acc As NTAccount = New NTAccount(lblPrincipal.Text) Dim secId As SecurityIdentifier = TryCast(acc.Translate(GetType(SecurityIdentifier)), SecurityIdentifier) Dim dirSec As DirectorySecurity = Directory.GetAccessControl(lblFolderPath.Text) Dim authRules As AuthorizationRuleCollection = dirSec.GetAccessRules(True, True, GetType(SecurityIdentifier)) For Each ar As FileSystemAccessRule In authRules If secId.CompareTo(TryCast(ar.IdentityReference, SecurityIdentifier)) = 0 Then Dim fileSystemRights = ar.FileSystemRights Console.WriteLine(fileSystemRights) If fileSystemRights.HasFlag(FileSystemRights.FullControl) Then chkFull.Checked = True End If If fileSystemRights.HasFlag(FileSystemRights.Traverse) Then chkTraverse.Checked = True End If If fileSystemRights.HasFlag(FileSystemRights.ReadData) Then chkReadData.Checked = True End If If fileSystemRights.HasFlag(FileSystemRights.ReadAttributes) Then chkReadAttributes.Checked = True End If If fileSystemRights.HasFlag(FileSystemRights.ReadExtendedAttributes) Then chkReadExtendedAttributes.Checked = True End If If fileSystemRights.HasFlag(FileSystemRights.CreateFiles) Then chkCreateFiles.Checked = True End If If fileSystemRights.HasFlag(FileSystemRights.CreateDirectories) Then chkCreateFolders.Checked = True End If If fileSystemRights.HasFlag(FileSystemRights.WriteAttributes) Then chkWriteAttributes.Checked = True End If If fileSystemRights.HasFlag(FileSystemRights.WriteExtendedAttributes) Then chkWriteExtendedAttributes.Checked = True End If If fileSystemRights.HasFlag(FileSystemRights.DeleteSubdirectoriesAndFiles) Then chkDeleteSubfolders.Checked = True End If If fileSystemRights.HasFlag(FileSystemRights.Delete) Then chkDelete.Checked = True End If If fileSystemRights.HasFlag(FileSystemRights.ReadPermissions) Then chkReadPermission.Checked = True End If If fileSystemRights.HasFlag(FileSystemRights.ChangePermissions) Then chkChangePermission.Checked = True End If If fileSystemRights.HasFlag(FileSystemRights.TakeOwnership) Then chkTakeOwnership.Checked = True End If End If Next
解决方案
这篇关于如何获取特定用户的目录高级权限?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!