Tivoli C library and unsafe C# (a void** problem)

  • Thread starter Francois Vanderseypen
  • Start date
F

Francois Vanderseypen

I have a C-library API to the Tivoli LDAP allowing to manage users and
groups.
The user management is an ASP.Net application and this library should
update/synchronize the LDAP.

The C-lib signature is:

int SIT_Registry_Initialise( void ** _LdapSession ,
char* _szHost_Port,
char* _szAdmin_DN,
char* _szAdmin_Pwd);

I understand that the void** is a "byref" argument. The _LdapSession
is passed (as a connection object) to other calls thereafter. I guess
the _LdapSession is a C-structure.

How should I wrap this dll function?

At this moment it looks like:

[DllImport("SIT_UML.dll", EntryPoint="SIT_Registry_Initialise")]public
static extern int InitializeRegistry([MarshalAs(UnmanagedType.AsAny)]UIntPtr
LDAPSession,[MarshalAs(UnmanagedType.LPStr)]string
HostPort,[MarshalAs(UnmanagedType.LPStr)]string
AdminUserID,[MarshalAs(UnmanagedType.LPStr)]string AdminPassword);

and the actual call is:

UIntPtr LDAPSession=UIntPtr.Zero;
int ret=UML.InitializeRegistry(LDAPSession,"blabla","blabla","blabla");


Thanks for any help!
 
M

Mattias Sjögren

Francois,
How should I wrap this dll function?

At this moment it looks like:

[DllImport("SIT_UML.dll", EntryPoint="SIT_Registry_Initialise")]public
static extern int InitializeRegistry([MarshalAs(UnmanagedType.AsAny)]UIntPtr
LDAPSession,[MarshalAs(UnmanagedType.LPStr)]string
HostPort,[MarshalAs(UnmanagedType.LPStr)]string
AdminUserID,[MarshalAs(UnmanagedType.LPStr)]string AdminPassword);

Make LDAPSession a ref or out parameter, and remove the MarshalAs
attribute on it.



Mattias
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top