473,395 Members | 1,629 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.

LDAPMod structure

Hi,

I'm trying to use ldap_modify_s and it requires use of the LDAPMod
structure. Anyone have any idea how toadapt this for .NET. I keep
getting an error 53 (Unwilling to perform) when using the structure.

Here is what I have:

[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto )]
public struct LDAPMod
{
public int mod_op;
public string mod_type;
public struc_mod_vals[] mod_vals;
}

[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto )]
public struct struc_mod_vals
{
public string[] modv_strvals;
public object modv_bvals;
}

Thanks!

Nov 17 '05 #1
1 1543
Stefan,

The marshaling layer doesn't really support structures that have
pointers in them well. You will want to define your structures like this:

[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Unicode)]
public struct LDAPMod
{
public int mod_op;
public string mod_type;
public IntPtr mod_vals;
}

[StructLayout(LayoutKind.Sequential)]
public struct berval
{
public int bv_len;
IntPtr bv_val;
}

You need the CharSet set to Unicode on the first structure because
mod_type is defined as PWCHAR, which is a wide character. Also, if this
structure is being populated on return, you might have to change the
declaration to IntPtr, since you will be responsibile for freeing that
memory allocated (and the runtime does not know how to do it).

The mod_vals field you will have to marshal on your own. The mod_vals
field contains a pointer to an array of berval structures, all of which you
will have to marshal on your own (as well as marshal the data pointed to by
bv_val).

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Stefan Buchman" <st************@gmail.com> wrote in message
news:11*********************@g43g2000cwa.googlegro ups.com...
Hi,

I'm trying to use ldap_modify_s and it requires use of the LDAPMod
structure. Anyone have any idea how toadapt this for .NET. I keep
getting an error 53 (Unwilling to perform) when using the structure.

Here is what I have:

[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto )]
public struct LDAPMod
{
public int mod_op;
public string mod_type;
public struc_mod_vals[] mod_vals;
}

[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto )]
public struct struc_mod_vals
{
public string[] modv_strvals;
public object modv_bvals;
}

Thanks!

Nov 17 '05 #2

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

Similar topics

2
by: vikas | last post by:
I have following structure in c++. typedef struct MMF_result_struct { int action; char text; int cols,rows; int month,day,year; } MMF_result; Now this structure is shared between C++ and C#...
26
by: Brett | last post by:
I have created a structure with five fields. I then create an array of this type of structure and place the structure into an array element. Say index one. I want to assign a value to field3 of...
4
by: marco_segurini | last post by:
Hi, From my VB program I call a C++ function that gets a structure pointer like parameter. The structure has a field that contains the structure length and other fields. My problem is that...
2
by: Steve Turner | last post by:
I have read several interesting posts on passing structures to C dlls, but none seem to cover the following case. The structure (as seen in C) is as follows: typedef struct tag_scanparm { short...
8
by: Charles Law | last post by:
Can anyone suggest how I would marshal a variable length structure back from an API call. Specifically, I am looking at the WaitForDebugEvent function, which returns a DEBUG_EVENT structure. ...
15
by: Charles Law | last post by:
I have adapted the following code from the MSDN help for PropertyInfo SetValue. In the original code, the structure MyStructure is defined as a class MyProperty, and it works as expected. There is...
3
by: Kiran B. | last post by:
Hi, I am new to .net. I have two Data Structure Type ... Sturcture A and Structure B. Structure A Public Fname as String Public LastName as String Public City as String Public Zip as String...
10
by: David Fort | last post by:
Hi, I'm upgrading a VB6 app to VB.net and I'm having a problem with a call to a function provided in a DLL. The function takes the address of a structure which it will fill in with values. I...
5
by: =?Utf-8?B?QXlrdXQgRXJnaW4=?= | last post by:
Hi Willy, Thank you very much for your work. C++ code doesnot make any serialization. So at runtime C# code gives an serialization error at "msg_file_s sa = (msg_file_s) bf.Deserialize(ms);"...
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
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.