473,563 Members | 2,504 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Converting a security descriptor

In a C# application I'm using the NetShareGetInfo API function to get some
information about a share.
This is working all right.

Now I want my application to be able to display the contents of the security
descriptor as well.
Using NetShareGetInfo I get a IntPtr (SECURITY_DESCR IPTOR*) to the security
descriptor. I would like to convert this into an
ActiveDs.IADsSe curityDescripto r.

I've tried the following:
ActiveDs.IADsSe curityDescripto r sd =
(ActiveDs.IADsS ecurityDescript or)securityUtil ity.ConvertSecu rityDescriptor( pSd1,
2, 1);
but it throws an exception 0x8000500C.

Can this be done at all ? And if so, how ???

It seems like it possible to get the SD by using
IADsSecurityUti lity::GetSecuri tyDescriptor. However as I allready have the
data from NetShareGetInfo , I would just like to convert it into a format
easier to work with.
Thanks in advace,
Jan Nielsen
Nov 16 '05 #1
1 8686

"Jan Nielsen" <ja*******@onli ne.nospam> wrote in message
news:uI******** ******@tk2msftn gp13.phx.gbl...
In a C# application I'm using the NetShareGetInfo API function to get some
information about a share.
This is working all right.

Now I want my application to be able to display the contents of the
security descriptor as well.
Using NetShareGetInfo I get a IntPtr (SECURITY_DESCR IPTOR*) to the
security descriptor. I would like to convert this into an
ActiveDs.IADsSe curityDescripto r.

I've tried the following:
ActiveDs.IADsSe curityDescripto r sd =
(ActiveDs.IADsS ecurityDescript or)securityUtil ity.ConvertSecu rityDescriptor( pSd1,
2, 1);
but it throws an exception 0x8000500C.

Can this be done at all ? And if so, how ???

It seems like it possible to get the SD by using
IADsSecurityUti lity::GetSecuri tyDescriptor. However as I allready have the
data from NetShareGetInfo , I would just like to convert it into a format
easier to work with.
Thanks in advace,
Jan Nielsen


Jan,

You can't pass a raw pointer as argument to ConvertSecurity Descriptor, this
method takes a VARIANT of type byte array (VT_I1|VT_ARRAY ).
So you have to marshal the SD to a byte[] with correct length.
To get the lenght of the SD call GetSecurityDesc riptorLength, here's the
signature:

[DllImport("adva pi32", SetLastError=tr ue)]
internal static extern uint GetSecurityDesc riptorLength(In tPtr byteArray);

uint sdLength = GetSecurityDesc riptorLength(pS d1);

Now create an array with the length returned using Marshal.Copy and call
your method like this:

byte[] sdArray = new byte[sdLength];
Marshal.Copy(pS d1, buffer1, 0, (int) sdLength);
ADsSecurityUtil ityClass asu = new ADsSecurityUtil ityClass();
IADsSecurityDes criptor sdi =
(IADsSecurityDe scriptor)asu.Co nvertSecurityDe scriptor(sdArra y,2, 1);

As you see, you need another PInvoke call, and that's bad, there's no need
to call NetShareGetInfo , you better stick to System.Director yServices to get
the SD from a remote share.

Willy.
Nov 16 '05 #2

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

Similar topics

1
2237
by: Luke Wojtow | last post by:
Hi all, http://bugs.mysql.com/bug.php?id=3779 Discussion about insecurity of mysql_pconnect in multi-server/multi-user environment.Can anyone explain what Hartmut Holzgraefe meant by "But even if close_on_exec were set on PHP->MySQL connections there would still be the risk of connection hijacking with PHP pconnect as any other piece of...
1
3018
by: Duncan Allen | last post by:
Hi, Using VB.NET I need to access a shared drive on a server using a specific account, check for a subdirectory, add it if it doesn't exist and then change the access security for the subdirectory to only allow specific accounts to access it - these will be different to the account used by the app. Thanks for your help.
1
2642
by: Danko Greiner | last post by:
Thanx Willy, this was very helpful. But i also need (and want to know) how to do this from code. Can you plase give me right topic in MSDN? is there good example? Thanx p.s. this is copy/paste from previous thread, don't ask why... "Grei" <danko.greinerREMOVE@zg.htnet.hr> wrote in message news:d1vihg$m3b$1@ss405.t-com.hr...
5
2506
by: Robert | last post by:
I have a series of web applications (configured as separate applications) on a server. There is a main application at the root and then several virtual directories that are independant applications. I am testing an upgrade of all of the sites and have converted the main root site...although not necessarily fixed any issues. I move on...
0
3830
by: ChrisWoodruff | last post by:
I have a C++ function in a COM object that I am trying to implement in VB.NET (the functionality, NOT the COM object, I want to remove the requirement for the COM DLL) I am an experienced VB programmer, but this is my first .NET app... Original Code (what I have been doing and works) VB6 (extra stuff removed for clarity) Set objWbem =...
2
1254
by: Yosh | last post by:
How do you validate a user that is currently logged in against a Security Descriptor to see if they have access to an object? Hope this makes sense. Thanks, Yosh
1
3217
by: Huayang Xia | last post by:
I'd like to call pythoncom.CoInitializeSecurity with a PySecurityDescriptor object to set the process-wide security values. But I'm not able to find a way to let the code go through. I have read MSDN and searched web, I've not been able to find answer. I cooked a security descriptor like this (assume aces is a tuple of tuple (access, sid) :
1
1529
by: Surfy wu | last post by:
HI all: Call poll() function at two threads, and the important is the two threads are waitting for the same socket descriptor . one of them is set POLLIN , the other is set POLLOUT. What i want to know is whether i should protect the socket descriptor by using lock. thanks advance
3
2022
by: Eric Mahurin | last post by:
Is there a standard way to get a descriptor object for an arbitrary object attribute - independent of whether it uses the descriptor/ property protocol or not. I want some kind of handle/reference/ pointer to an attribute. I know I could make my own class to do this (using the __dict__ of the object and the attribute name), but I would like...
0
7658
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7579
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
1
7631
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6238
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5479
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5204
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3631
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3615
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2077
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 we have to send another system

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.