使用j-Interop查询共享目录

这里主要使用WMI查询共享目录得到目录信息与相应的共享权限信息,j-Interop的jar请在http://t42dw.iteye.com/blog/790855下载

 

VB代码

strComputer = "y55302b.china.huawei.com"
'strComputer = "10.69.30.152"
Set wbemServices = Getobject("winmgmts:\\" & strComputer)
'Set wbemObjectSet = wbemServices.get("Win32_LogicalShareSecuritySetting.Name='sql'") 

Set wbemObjectSetArray = wbemServices.ExecQuery("select * from Win32_LogicalShareSecuritySetting") 
 
For Each wbemObjectSet In wbemObjectSetArray

RetVal = wbemObjectSet.GetSecurityDescriptor(wmiSecurityDescriptor)
DACL =wmiSecurityDescriptor.DACL

WScript.Echo wbemObjectSet.Name

For Each daclValue In DACL
WScript.Echo daclValue.AceType
WScript.Echo daclValue.AccessMask

' Get Win32_Trustee object from ACE 
Set Trustee = daclValue.Trustee
    wscript.echo "Trustee Domain: "  & Trustee.Domain
    wscript.echo "Trustee Name: "    & Trustee.Name

' Get SID as array from Trustee
    SID = Trustee.SID 
    strsid = join(SID, ",") 
    wscript.echo "Trustee SID: {" & strsid & "}"

Next

Next

 

 

java代码请看附件!

你可能感兴趣的:(sql,Blog,J#,vb)