Anonymous_User Absent Member.
Absent Member.
391 views

Re: Get logged Username and Context

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?
>
>

Labels (1)
0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.