473,394 Members | 1,802 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,394 software developers and data experts.

setting and retrieving NTFS permissons for local groups and users

Neo
Hi Everyone
I am trying to set and retrieve NTFS permssions for
fileshares on remote machine using ActiveDs Interop. It works for domain
groups and users but when try to retrieve permssions for local groups and
users it gives me dangling SIDs. While setting permssions how can I indicate
whether the user or group is local or a domain group ?.
Following is the code snippet I am using for retrieving permissions

string folderPath = @"\\machinename\e$\test";

IADsAccessControlList daclnew ;

ADsSecurityUtilityClass secuUtil = new ADsSecurityUtilityClass();

//Getting security decriptor

object ob = secuUtil.GetSecurityDescriptor(

folderPath,

(int)ActiveDs.ADS_PATHTYPE_ENUM.ADS_PATH_FILE,

(int)ActiveDs.ADS_SD_FORMAT_ENUM.ADS_SD_FORMAT_IID

);

ActiveDs.IADsSecurityDescriptor securitydescriptor =
(IADsSecurityDescriptor)ob;

ActiveDs.IADsAccessControlList obDacl = ( ActiveDs.IADsAccessControlList )

securitydescriptor.DiscretionaryAcl;

daclnew = (IADsAccessControlList)obDacl;

foreach(IADsAccessControlEntry entry in daclnew)

{

if( entry.AceType == (int)ADS_ACETYPE_ENUM.ADS_ACETYPE_ACCESS_ALLOWED )

{

Console.WriteLine( entry.Trustee );

}

}
Following is the code snippet I am using to set permssion:

ADsSecurityUtilityClass secuUtil = new ADsSecurityUtilityClass();

//Getting security decriptor

object ob = secuUtil.GetSecurityDescriptor(

folderPath,

(int)ActiveDs.ADS_PATHTYPE_ENUM.ADS_PATH_FILE,

(int)ActiveDs.ADS_SD_FORMAT_ENUM.ADS_SD_FORMAT_IID

);

if ( null != ob )

{

ActiveDs.IADsSecurityDescriptor securitydescriptor =
(IADsSecurityDescriptor)ob;
if( allowTrusteeList != null )

{

for( int trustee = 0; trustee < allowTrusteeList.Length; trustee++ )

{

ActiveDs.IADsAccessControlList obDacl = (
ActiveDs.IADsAccessControlList )

securitydescriptor.DiscretionaryAcl;

Allow = new AccessControlEntryClass();

//For recursive security settings

Allow.AceFlags = 3;

//ACE is allow type

Allow.AceType = (int)ADS_ACETYPE_ENUM.ADS_ACETYPE_ACCESS_ALLOWED;

//storing trustee

Allow.Trustee = SetSecurityTrustee( allowTrusteeList[trustee] );

//Allow.Trustee = allowTrusteeList[trustee];

AppendLog( 1, "Creating allow accessmask for trustee: " +
allowTrusteeList[trustee] );

//creating access mask

if( !CreateAccessMask( Allow, true, trustee ) )

{

return false;

}

obDacl.AddAce(Allow);

}


Nov 15 '05 #1
0 1793

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

Similar topics

1
by: BingoHandJob | last post by:
Hello group! I'm having a problem and I hope some of you may be able to point me in the right direction. I inherited a web site using php, running on Windows 2000 & IIS. The site was...
2
by: travelling_nerd | last post by:
Folks: I have some zip files I'd like to serve to authenticated users on my site, but would like to prevent unauthorized users from using an absolute path to get to these zip files. For example...
3
by: Kim Lots | last post by:
Hi folks Let say I have one virtual directory (IIS 5.x) pointing to a folder on my G: drive what would be the minimum NTFS permissions (w2k pro) for users & groups on this folder considering I'm...
5
by: travelling_nerd | last post by:
Hi, I'm trying to write a script that will allow validated users to download a file that has specific ntfs permissions. Here's a summary: Scenario: 1) The name of the file is "binary.zip"....
1
by: tangus via DotNetMonster.com | last post by:
Hello all, I'm really struggling with getting some Active Directory code to work in ASP.NET. Can you please provide assistance? I am executing the following code: Dim enTry As DirectoryEntry =...
0
by: Johan | last post by:
Hi I'm using WMI to set and remove folderpermissions and it sems to work fine, sometimes. I start by having the folderpermissons manuly set to Everyone and Everone has full rights. When I'm...
1
by: laredotornado | last post by:
Hi, I'm using PHP 4.4.4 on Apache 2 on Fedora Core 5. PHP was installed using Apache's apxs and the php library was installed to /usr/local/php. However, when I set my "error_reporting"...
0
by: Mean | last post by:
Hello, I'm just writing a script that creates Groups in the AD. This groups are named by a special name convention (for our firm). I also set the "Scope of Group". Everything works very nice. ...
8
by: Michael Howes | last post by:
I have some code that manages local user logins. When I create a new user I want to set the password to expire every x days and the number of failed login attempts before the account is...
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
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.