473,472 Members | 1,746 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Writing ACL dont work

Hello NG!

Iam trying to write Access Control Settings for Users in Active Dir.
First what i do is to delegate a Trustee in a Container, with
permissions. This works fine. Lets take Guests as Trustee. Setting
rights like "Full Control" or "Read" or "Write" is not the issue, my
problem ar the Subrights like "Read logon time" or write "logon time"
i cannot achieve this. Ok heres some code:

using ActiveDs;

AccessControlEntry newAce = new AccessControlEntryClass();
SecurityDescriptor usrSD =
(SecurityDescriptor)src.Properties["ntSecurityDescriptor"].Value;
AccessControlList usrAcl= (AccessControlList) usrSD.DiscretionaryAcl;
ADsSecurityUtilityClass asu = new ADsSecurityUtilityClass();
asu.SecurityMask=(int)(ADS_SECURITY_INFO_ENUM.ADS_ SECURITY_INFO_DACL);
newAce.Flags=(int)ActiveDs.ADS_FLAGTYPE_ENUM.ADS_F LAG_INHERITED_OBJECT_TYPE_PRESENT
| (int)ActiveDs.ADS_FLAGTYPE_ENUM.ADS_FLAG_OBJECT_TY PE_PRESENT;
newAce.AceType=aceType;
newAce.AccessMask=accessMask;
newAce.AceFlags=aceFlags;

//Problems must be here! or the newAce.Flags Attribute!
newAce.ObjectType="{28630ebf-41d5-11d1-a9c1-0000f80367c1}";
newAce.InheritedObjectType="{bf967aba-0de6-11d0-a285-00aa003049e2}";
//Here we go with the SubRights like "Lockout Time"
//here i set "Lockout time", wich dont work, no error, no exception!
newAce.Trustee=GetTextualSID(de);
usrAcl.AddAce(newAce);
usrSD.DiscretionaryAcl=usrAcl;
src.Properties["ntSecurityDescriptor"].Value=usrSD;
src.CommitChanges();


OK everything works except those lines:
1.newAce.Flags....
2.newAce.ObjectType...
3.newAce.InheritedObjectType...

I have tried same stuff in VB wich worked without a Problem!!!!! ( ???
)
Here is the VB Code wich works fine! :

(Mention: not posted the declaration of the ADS variables!)

' ADS_FLAG_OBJECTS
Public Const ADS_FLAG_OBJECT_TYPE_PRESENT = &H1
Public Const ADS_FLAG_INHERITED_OBJECT_TYPE_PRESENT = &H2
' Delegation der Admin-OU
Set ou = GetObject("LDAP://ou=123,ou=agis,dc=adtsfbbd3,dc=adtsfbb,dc=net")
Set sec = ou.Get("ntSecurityDescriptor")
Set acl = sec.DiscretionaryAcl
Set ace = CreateObject("AccessControlEntry")
' You can also use Set ace = new ADsAccessControlEntry.

' Grant access to the object.
ace.AceType = ADS_ACETYPE_ACCESS_ALLOWED_OBJECT

' Create and delete child objects.
ace.AccessMask = ADS_RIGHT_DS_READ_PROP or ADS_RIGHT_DS_WRITE_PROP

' Attribute LockOutTime
ace.ObjectType = "{28630ebf-41d5-11d1-a9c1-0000f80367c1}"

' User object class of the schema IDGUID.
ace.InheritedObjectType = "{bf967aba-0de6-11d0-a285-00aa003049e2}"

' Propagate the ACE down.
ace.AceFlags = ADS_ACEFLAG_INHERIT_ACE

' Provide an option that notifies that the objectType is filled.
ace.Flags = ADS_FLAG_OBJECT_TYPE_PRESENT or
ADS_FLAG_INHERITED_OBJECT_TYPE_PRESENT

' Show the beneficiary of this ACE.
ace.Trustee = "adtsfbbd3\test123"
acl.AddAce ace

sec.DiscretionaryAcl = acl
ou.Put "ntSecurityDescriptor", Array(sec)
' Use SetInfo to commit the data to Active Directory.
ou.SetInfo
If Err.number<>0 Then
MsgBox "Delegation nicht eingerichtet.",48
Wscript.Quit
End If

' Release the objects.
Set ace = Nothing
Set acl = Nothing
Set sec = Nothing
MsgBox "Delegation von LockOutTime der Gruppe " & strGroup & "
durchgefuehrt.
So why this works under VB but doesnt work under C#? What iam doing
wrong??
Thank u all very much !

Regards Sebastian
Nov 15 '05 #1
1 2576
On 2 Sep 2003 01:28:51 -0700, se*************@dregis.com (Sebastian
Sosna) wrote:
' Show the beneficiary of this ACE.
ace.Trustee = "adtsfbbd3\test123"
acl.AddAce ace


try to alter the Trustee to @"adtsfddb3\test123"; <=Place a '@' before
the string
C# uses \ for escape characters in strings...:
\t = tab
\n = newline
...
Usage of @ in front of the string (like this: @"my\nstring") will
disable excape chars for that string (the result here will be
'my\nstring' instead of - for vb: "my" & vbCrLf & "string")

that might be it...
--
NULL

Nov 15 '05 #2

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

Similar topics

11
by: lawrence | last post by:
I asked a lot of questions in May about how to organize OO code. I didn't get great answers here, but someone here suggested that I look the Eclipse library, which was a good tip. Looking at its...
0
by: Farooq Khan | last post by:
hi, my development team has been assigned a project that involves writing our own Web service. i happen to be a C++ programmer, new to C#/ASP.net. i dont know where to begin with......any...
10
by: Kristian Nybo | last post by:
Hi, I'm writing a simple image file exporter as part of a school project. To implement my image format of choice I need to work with big-endian bytes, where 'byte' of course means '8 bits', not...
19
by: Noozer | last post by:
I need to keep my application settings in a file that users can copy/backup/etc. Before I start using the old INI file standard, is there any easy way to use XML files to hold application...
6
by: dast | last post by:
Hello, I’m having trouble writing the contents of a dataset to a csv file. I have made a solution that loops through the rows in the dataset, but it’s too slow. There must be a faster and...
12
by: Chris Springer | last post by:
I'd like to get some feedback on the issue of storing data out to disk and where to store it. I've never been in a production environment in programming so you'll have to bear with me... My...
3
by: localpricemaps | last post by:
i am having a problem writing a tuple to a text file. my code is below. what i end up getting is a text file that looks like this burger, 7up burger, 7up burger, 7up and this is instead...
3
by: lucky | last post by:
Hi guys, i want to write some data in tabular format in text file. i've data in strings and i want to write like this in file col1 col2 col3 d1 d1 d1 d2 d2 ...
6
by: Mizipzor | last post by:
Hi, this is my first mail to the list (and any list for that matter) so any pointers on errors from my part would be appreciated. Im more used to forums. To start off, Ive read some python...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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,...
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...
1
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...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.