I am looking for a way to convert the following vbs script to c#
Const ADS_SECURE_AUTHENTICATION = 1
strADMIN = "adminaccount"
strPASSWORD = "password"
strUSER = "useraccount"
Set dso = GetObject("WinNT:")
Set srv = DSO.OpenDSObject("WinNT://servername/LanmanServer", strADMIN,
strPASSWORD, ADS_SECURE_AUTHENTICATION)
Set colResources = srv.Resources
For Each objResource in colResources
If objResource.User = strUSER Then objResource.remove(objResource.Name)
Next
I have seen various c# code using DirectoryServices with the winnt:
provider to enumerate users, groups, shares, etc
But I cant seem to find out how to gather open file or session information.
I know that he below code would show me shares on a file server,
but how do I get it to show me open files and sessions ?
using System;
using System.DirectoryServices;
namespace NetAcademia.Samples
{
class App
{
static void Main()
{
DirectoryEntry root = new DirectoryEntry
("WinNT://servername/lanmanserver");
foreach(DirectoryEntry child in root.Children)
{
Console.WriteLine(child.Name);
}
}
}
}
Thanks for any insight or help with this problem
Rich