473,388 Members | 1,326 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

How to create share only to one user ?

My code goes here following, but it can't work, why ? Bytheway,if only one
user should be permitted to accesss it,how can i do ? thx!

static void Main(string[] args)
{
try
{
ManagementObject v_theTrusteeObject = new
ManagementClass("Win32_Trustee").CreateInstance();
Object[] v_theSID = {1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0};
v_theTrusteeObject["Domain"] = null;
v_theTrusteeObject["Name"] = "Everyone";
v_theTrusteeObject["SID"] = v_theSID;

ManagementObject v_theAceObject = new
ManagementClass("Win32_Ace").CreateInstance();
v_theAceObject["AccessMask"] = 2032127;
v_theAceObject["AceFlags"] = 3;
v_theAceObject["AceType"] = 0;
v_theAceObject["Trustee"] = v_theTrusteeObject;

ManagementObject v_theSecDescObject = new
ManagementClass("Win32_SecurityDescriptor").Create Instance();
Object[] v_theAceArray = { v_theAceObject };
v_theSecDescObject["DACL"] = v_theAceArray;

ManagementClass v_theShareClass = new
ManagementClass("Win32_Share");
ManagementBaseObject v_theShareArguments =
v_theShareClass.GetMethodParameters("Create");
v_theShareArguments["Path"] = @"D:\Media";
v_theShareArguments["Name"] = "Media";
v_theShareArguments["Type"] = 0;
v_theShareArguments["Access"] = v_theSecDescObject;

ManagementBaseObject v_theCreateResult =
v_theShareClass.InvokeMethod("Create", v_theShareArguments, null);
Console.WriteLine(v_theCreateResult.GetText(TextFo rmat.Mof));

foreach (ManagementObject v_aShareObject in
(new ManagementObjectSearcher("select * from
Win32_Share")).Get())
{
Console.WriteLine(v_aShareObject["Name"]);
}
}
catch(Exception v_theConnectionException)
{
Console.WriteLine(v_theConnectionException.ToStrin g());
}
}
Oct 23 '06 #1
1 1786
help!

"HuffmaN" <hu***********@gmail.comдÈëÏûÏ¢ÐÂÎÅ:uB*********** **@TK2MSFTNGP05.phx.gbl...
My code goes here following, but it can't work, why ? Bytheway,if only one
user should be permitted to accesss it,how can i do ? thx!

static void Main(string[] args)
{
try
{
ManagementObject v_theTrusteeObject = new
ManagementClass("Win32_Trustee").CreateInstance();
Object[] v_theSID = {1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0};
v_theTrusteeObject["Domain"] = null;
v_theTrusteeObject["Name"] = "Everyone";
v_theTrusteeObject["SID"] = v_theSID;

ManagementObject v_theAceObject = new
ManagementClass("Win32_Ace").CreateInstance();
v_theAceObject["AccessMask"] = 2032127;
v_theAceObject["AceFlags"] = 3;
v_theAceObject["AceType"] = 0;
v_theAceObject["Trustee"] = v_theTrusteeObject;

ManagementObject v_theSecDescObject = new
ManagementClass("Win32_SecurityDescriptor").Create Instance();
Object[] v_theAceArray = { v_theAceObject };
v_theSecDescObject["DACL"] = v_theAceArray;

ManagementClass v_theShareClass = new
ManagementClass("Win32_Share");
ManagementBaseObject v_theShareArguments =
v_theShareClass.GetMethodParameters("Create");
v_theShareArguments["Path"] = @"D:\Media";
v_theShareArguments["Name"] = "Media";
v_theShareArguments["Type"] = 0;
v_theShareArguments["Access"] = v_theSecDescObject;

ManagementBaseObject v_theCreateResult =
v_theShareClass.InvokeMethod("Create", v_theShareArguments, null);

Console.WriteLine(v_theCreateResult.GetText(TextFo rmat.Mof));

foreach (ManagementObject v_aShareObject in
(new ManagementObjectSearcher("select * from
Win32_Share")).Get())
{
Console.WriteLine(v_aShareObject["Name"]);
}
}
catch(Exception v_theConnectionException)
{
Console.WriteLine(v_theConnectionException.ToStrin g());
}
}


Oct 24 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: jiing | last post by:
I want to use web interface to do : 1. user accounts management (adminstration side) 2. personal password management (user side) 3. create actual accounts under windows 2003 server( for handling...
4
by: Dave | last post by:
I have an application where I am providing the user the ability to select or create a folder on a domain, using SHBrowseForFolder. When the user selects/creates a folder on a remote computer, it...
6
by: Frank Wilson | last post by:
Tom, It sounds to me like ASP, not ASP.NET is handling the request for WebForm1.aspx. This is most likely an IIS config issue that may have been caused by order of installation or...
4
by: TimC | last post by:
I hope someone can help - I am getting desperate! I have promised to do some work for someone developing an ASP.NEt application. I have VS Studio 2002 installed on my pc which is running...
11
by: Andre | last post by:
Hi, I have ASP.NET application running on standalone (not part of the domain) Windows 2003. I use forms authentication for my application. The problem I have is that I need to create and read...
2
by: freenews.netfront.net | last post by:
Hi, I am writing an asp.net / Active Directory application using vb.net in it's code-behind pages. The app is running on the W2k3 (r1) domain controller (e.g. server1). Does anyone know how...
0
by: Torsten Valentin | last post by:
Hi! I have to write a program that should create a new directory ("c:\test") and share that directory with read-access for everyone and read-write-access for administrators. How do I do that in...
0
by: Torsten Valentin | last post by:
Hi! I am working on a program that should create a new directory ("c:\test") and share that directory with read-access for everyone and read-write-access for administrators. How do I do that in...
2
by: yxq | last post by:
Hello I want to create and delete the folder share, i found that it is ok for generic folder, but it does not work for Root directory(i.e c:\, d:\) The code...
0
by: Johnny Fugazzi | last post by:
Basic question. I am working on an app that needs to open an excel file an read out data. Have posted a little about this before. The excel file is secured and the user cannot acces it. I...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.