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

ObjectPicker Wrapper and Marshaling

I'm tring to implement the ObjectPicker for a project I'm working on. I'm
using the DSObjectPickerWrapper found at
http://dotnet.org.za/armand/articles/2453.aspx

This works fine as is, but I need to get additional Attributes back from the
Picker specifically "objectSid" Unfortunately, I can figure out how to
marshal the initInfo.apwzAttributeNames Property. In the API documention
for the ObjectPicker, it is defined as a PCWSTR data type "Pointer to an
array of null-terminated Unicode strings that contain the names of the
attributes to retrieve for each selected object."

I've tried this several ways, but I can't figure out how to properly marshal
this datatype. Here is the code for the Initialize Method

private IDsObjectPicker Initialize()
{

DSObjectPicker picker = new DSObjectPicker();

IDsObjectPicker ipicker = (IDsObjectPicker)picker;

DSOP_SCOPE_INIT_INFO[] scopeInitInfo = new
DSOP_SCOPE_INIT_INFO[2];

// Initialize 1st search scope

scopeInitInfo[0].cbSize =
(uint)Marshal.SizeOf(typeof(DSOP_SCOPE_INIT_INFO)) ;

scopeInitInfo[0].flType =
DSOP_SCOPE_TYPE_FLAGS.DSOP_SCOPE_TYPE_GLOBAL_CATAL OG;
//Convert.ToUInt32("3FE",16);

scopeInitInfo[0].flScope =
DSOP_SCOPE_INIT_INFO_FLAGS.DSOP_SCOPE_FLAG_DEFAULT _FILTER_COMPUTERS + 1; //
Starting !?

scopeInitInfo[0].FilterFlags.Uplevel.flBothModes =
DSOP_FILTER_FLAGS_FLAGS.DSOP_FILTER_COMPUTERS + 1; // +1 = advanced view,
Check MSDN for the available options

scopeInitInfo[0].FilterFlags.flDownlevel =
DSOP_DOWNLEVEL_FLAGS.DSOP_DOWNLEVEL_FILTER_COMPUTE RS;

scopeInitInfo[0].pwzADsPath = null;

scopeInitInfo[0].pwzDcName = null;

scopeInitInfo[0].hr = 0;

// Initialize 2nd search scope

scopeInitInfo[1].cbSize =
(uint)Marshal.SizeOf(typeof(DSOP_SCOPE_INIT_INFO)) ;

scopeInitInfo[1].flType = Convert.ToUInt32("37F",16);

scopeInitInfo[1].flScope =
DSOP_SCOPE_INIT_INFO_FLAGS.DSOP_SCOPE_FLAG_DEFAULT _FILTER_USERS |

DSOP_SCOPE_INIT_INFO_FLAGS.DSOP_SCOPE_FLAG_DEFAULT _FILTER_GROUPS;

scopeInitInfo[1].FilterFlags.Uplevel.flBothModes =
Convert.ToUInt32("3FF",16);

scopeInitInfo[1].FilterFlags.flDownlevel =
DSOP_DOWNLEVEL_FLAGS.DSOP_DOWNLEVEL_FILTER_ALL_WEL LKNOWN_SIDS + 7;

scopeInitInfo[1].pwzADsPath = null;

scopeInitInfo[1].pwzDcName = null;

scopeInitInfo[1].hr = 0;

// Allocate memory from the unmananged mem of the
process, this should be freed later!??

IntPtr refScopeInitInfo = Marshal.AllocHGlobal

(Marshal.SizeOf (typeof (DSOP_SCOPE_INIT_INFO)) *
2);

// Marshal structs to pointers

Marshal.StructureToPtr (scopeInitInfo[0],

refScopeInitInfo,true);

Marshal.StructureToPtr (scopeInitInfo[1],

(IntPtr) ((int) refScopeInitInfo + Marshal.SizeOf

(typeof (DSOP_SCOPE_INIT_INFO))),true);

// Initialize structure with data to initialize an
object picker dialog box.

DSOP_INIT_INFO initInfo = new DSOP_INIT_INFO ();

initInfo.cbSize = (uint) Marshal.SizeOf (initInfo);

initInfo.pwzTargetComputer = null; // local computer

initInfo.cDsScopeInfos = 2;

initInfo.aDsScopeInfos = refScopeInitInfo;

// Flags that determine the object picker options.
Allow user to select

// multiple objects and specify that this is not a
domain controller

initInfo.flOptions =
DSOP_INIT_INFO_FLAGS.DSOP_FLAG_MULTISELECT |
DSOP_INIT_INFO_FLAGS.DSOP_FLAG_SKIP_TARGET_COMPUTE R_DC_CHECK;

// We're not retrieving any additional attributes

initInfo.cAttributesToFetch = 0;

initInfo.apwzAttributeNames = IntPtr.Zero;

// Initialize the Object Picker Dialog Box with our
options

ipicker.Initialize (ref initInfo);

return ipicker;

}

Thanks in Advance for any assistance.

Rodger
Nov 16 '05 #1
0 13867

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

Similar topics

0
by: Arthur Autenzio | last post by:
I have written a managed C++ wrapper class around an old C++ DLL that I have to use in my application. My problem is I need to marshal a bunch of structures from C# to the C++ class. These...
5
by: VM | last post by:
What's marshalling? I've had to use it extensively for a project but I don't know what it means. I tried to look for a definition in the Internet but I couldn't find anything that would explain...
3
by: Rudy Velthuis | last post by:
Hello, Does anyone know how to create a struct that will marshal to the following C++ struct A, containing an array of the user defined String10 type: struct String10 { char SLen; char S;
1
by: Nadav | last post by:
Hi I am about to write a performance crutial system, I am considering writing this system based on native COM or unmanaged C++ exposed as CLI, Now, I Wonder... does exposing a native code through...
1
by: C. N. Sridhar | last post by:
Hi, I'm writing a wrapper to a win32 dll in C#. I need to call a method in DLL which has a Variant type reference parameter. How to marshal variant type from win32 (unmanaged code) to C#...
1
by: Bill Medland | last post by:
I am trying to do some P/Invoke custom marshaling and am looking for a little help on custom marshaling a value type. I am working based on Kate Gregory's "Arranging Custom Marshaling With...
6
by: Aston Martin | last post by:
Hi All, ********************** My Situation ********************** I am working on project that involves passing a structure to unmanaged code from .Net world (well using C#). Perhaps an example...
0
by: tomwolfstein | last post by:
Hi. I am trying to write a wrapper for the standard VC1 decoder, and I need to resolve a "TypeLoadException" The decoder comes an an executable which I've turned into a .dll. This decoder has about...
0
by: jpogorman | last post by:
Hello, I am trying to get c# custom marshaling working in a particular scenario but it does not appear to be working or not jumping into my marshaling class when I try to debug it. I am try to...
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:
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
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: 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
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
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...

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.