I'm not too familiar with the internal data type format of C#, so I'm
moving on thin ice here.

However, the function NWDSWhoAmI() - like so many other DLL calls -
expects a pointer to a character array.

See also the .NET Marshalling concept
http://msdn.microsoft.com/en-us/library/s9ts558h.aspx

Did you try something like

> StringBuilder username = new StringBuilder(256);
> IcNovell.NWDSWhoAmI(context, username);


char* username = stackalloc char[256];
IcNovell.NWDSWhoAmI(context, username);


Wolfgang


On 31.05.2012 10:26, dimitribefuss wrote:
>
> Hello,
>
> for an application I need the current username and the context from the
> User. I insert the following C#-code:
>
>
> Code:
> --------------------
> public partial class Form1 : Form
> {
> public Form1()
> {
> InitializeComponent();
> }
>
> private void buttonGetNovellUserName_Click(object sender, EventArgs e)
> {
> int context = 0;
> IcNovell.NWDSCreateContextHandle(ref context);
> StringBuilder username = new StringBuilder(256);
> IcNovell.NWDSWhoAmI(context, username);
> labelUserName.Text = username.ToString();
> IcNovell.NWDSFreeContext(context);
> }
> }
>
> public class IcNovell
> {
> [DllImport("netwin32.dll", EntryPoint = "NWDSCreateContextHandle")]
> public static extern int NWDSCreateContextHandle(ref int context);
> [DllImport("netwin32.dll", EntryPoint = "NWDSWhoAmI")]
> public static extern int NWDSWhoAmI(int context, StringBuilder NovellUserId);
> [DllImport("netwin32.dll", EntryPoint = "NWDSFreeContext")]
> public static extern int NWDSFreeContext(int context);
> }
> --------------------
>
>
> I get the username but I don�t get the Context. There is only a "1" in
> the variable. Can someone help?
>
>