Login

  • Thread starter Thread starter Carlos M Perez
  • Start date Start date
C

Carlos M Perez

Hi all

I need to create a simply Windows CE application that logs against a
local area network domain. The form has three textboxes for the
domain, user name and password. I only need the code (C# or VB .NET)
for logging against the server. I've made my homework and I believe
I'll need to P/Invoke some API functions located on netui.dll, but
I've been unable to find *any* information about that API: I don't
have the slightest idea of the values of the constants and so on.

Please I'm desperate: I've been trying this for days and my job's on
the line.

Regards,
Carlos
 
I didn't think that the NETUI component had an publicly-documented API, but
I can find at least one of the functions exported by it,
GetUsernamePassword(), in the CE.NET 4.2 documentation. In my version of
the help, it's in the Application Development section, under Network User
Interface. I'm using, essentially, the Platform Builder help, so maybe that
explains why you can't find anything. You should be able to download an
evaluation version of PB from the Microsoft Web site...

Paul T.
 
First of all, thanks for your kind answer. Yes, I think I have some
good documentation (I'm consulting a CHM file called wcenetui.chm, I
don't know if it comes from PB or another SDK), but I have several
problems with this "helpful" file. :(

I have very little experience with P/Invoking, but if I could have the
exact data I need, I guess I would eventually make my invoking right,
thru work, work and work. But in the help file I'm consulting I have
the following definition of GetUserNamePassword:

BOOL GetUsernamePassword(
HWND hParent,
PNETUI_USERPWD pUserPwd
);

It uses an struct called PNETUI_USERPWD, which the help file defines
as:

typedef struct _NETUI_USERPWD {
TCHAR szUserName[UNLEN + 1];
TCHAR szPassword[PWLEN + 1];
TCHAR szDomain[DNLEN +1];
DWORD dwFlags;
TCHAR szResourceName[RMLEN];
} NETUI_USERPWD, *PNETUI_USERPWD;

It's all clear 'til it comes to flags. This
(NETUI_USERPWD_SERVERLOGON) is one of the values mentioned as one of
the possibilities for the dwFlags parameters. Guess what? I'ver been
*completely unable* to find any reference whatsoever to something
called NETUI_USERPWD_SERVERLOGON. I've searched Google (web,
directory, newsgroups, even images); I've searched my hard drive
looking for that string inside my files,... all to no avail.

The Help file mentions that NETUI_USERPWD_SERVERLOGON is defined on
netui.h, a header file I can't find *anywhere*. Not on the web, not on
my disk, not on my PDA.

To add injury to insult, the "Help" file mentions (and I'm
copy-pasting here):

"The source code for the implemented dialog boxes is in the
%_WINCEROOT%\Public\Common\Oak\Drivers\Netui directory."

And this is the exact moment when I'm starting to think about leaving
computers and beginning a new and not-so-stressing career, such as
fireman, test pilot, stunt double, or something like that.

Because, of course, I don't have the *slightest* idea of where the
hell is that path. And, of course, it's *not* on my hard disk and it's
*not* on my PDA. And I'm going crazy.

UPDATE: Right now I'm downloading WCE212QFE23.EXE from Microsoft. I do
hope this 189 Mbs file contains the netui.h, or some examples, or
something...

And on top of all this, I'm not even sure if this API function is
going to do what I need to do: to make a PDA perform a logon against a
LAN, specifying domain, username and password. The scenario is that my
client is going to have several PDAs for several employees, and
everyone of them should be able to use any of the PDAs, logon against
a LAN server and get their privileges, mapped connections and so on,
just as if they were to logon on a network-connected computer. If you
think of *ANY* way of doing this, please tell me.

One last thing: I hope you'll know to excuse the tone of this post.
I'm not angry (and of course I'm not angry *with you*; in fact I'm
really grateful to have someone to talk to about this), I'm
frustrated. Again, please excuse my tone if you found it offensive.


Thanks again for being there, Paul.

Regards,
Carlos
 
When you start doing a lot of work with calling API functions directly,
you're bound to run into a header file that you need which is missing
because it's part of the OS, but not included by the SDK. The SDK builder
part of Platform Builder is nowhere near 100% at including the right
(complete) set of header files for a given configuration.

I'm not sure what that file you are downloading is, but it *looks* like a
Windows CE QFE (a patch file for Platform Builder). If that's the case,
there's zero chance it has any samples in it. What you really want is the
full evaluation version of PB, which includes a few samples but, more
importantly, much of the source code for the OS, especially things like
netui. The path that you see mentioned there is a path under the Platform
Builder root.

As to your direct question, no, I don't know how to make the right thing pop
up, other than to try to connect to a shared resource, in which case the
network client seems to pop up the right log on dialog automatically. If
you just need to map a drive or whatever, maybe one of the WNetXXX functions
would implicitly do the log on for you.

By the way, the values of the three flags that you might use in
GetUsernamePassword are:

#define NETUI_USERPWD_SAVEPWD 0x00000001 // SavePwd box is checked
#define NETUI_USERPWD_SHOW_SAVEPWD 0x00000002 // Show the SavePwd control
#define NETUI_USERPWD_SERVERLOGON 0x00000004 // Connecting to network
server

from netui.h which is in <ce root>\public\common\oak\inc, once you install
PB.

Paul T.


Carlos M Perez said:
First of all, thanks for your kind answer. Yes, I think I have some
good documentation (I'm consulting a CHM file called wcenetui.chm, I
don't know if it comes from PB or another SDK), but I have several
problems with this "helpful" file. :(

I have very little experience with P/Invoking, but if I could have the
exact data I need, I guess I would eventually make my invoking right,
thru work, work and work. But in the help file I'm consulting I have
the following definition of GetUserNamePassword:

BOOL GetUsernamePassword(
HWND hParent,
PNETUI_USERPWD pUserPwd
);

It uses an struct called PNETUI_USERPWD, which the help file defines
as:

typedef struct _NETUI_USERPWD {
TCHAR szUserName[UNLEN + 1];
TCHAR szPassword[PWLEN + 1];
TCHAR szDomain[DNLEN +1];
DWORD dwFlags;
TCHAR szResourceName[RMLEN];
} NETUI_USERPWD, *PNETUI_USERPWD;

It's all clear 'til it comes to flags. This
(NETUI_USERPWD_SERVERLOGON) is one of the values mentioned as one of
the possibilities for the dwFlags parameters. Guess what? I'ver been
*completely unable* to find any reference whatsoever to something
called NETUI_USERPWD_SERVERLOGON. I've searched Google (web,
directory, newsgroups, even images); I've searched my hard drive
looking for that string inside my files,... all to no avail.

The Help file mentions that NETUI_USERPWD_SERVERLOGON is defined on
netui.h, a header file I can't find *anywhere*. Not on the web, not on
my disk, not on my PDA.

To add injury to insult, the "Help" file mentions (and I'm
copy-pasting here):

"The source code for the implemented dialog boxes is in the
%_WINCEROOT%\Public\Common\Oak\Drivers\Netui directory."

And this is the exact moment when I'm starting to think about leaving
computers and beginning a new and not-so-stressing career, such as
fireman, test pilot, stunt double, or something like that.

Because, of course, I don't have the *slightest* idea of where the
hell is that path. And, of course, it's *not* on my hard disk and it's
*not* on my PDA. And I'm going crazy.

UPDATE: Right now I'm downloading WCE212QFE23.EXE from Microsoft. I do
hope this 189 Mbs file contains the netui.h, or some examples, or
something...

And on top of all this, I'm not even sure if this API function is
going to do what I need to do: to make a PDA perform a logon against a
LAN, specifying domain, username and password. The scenario is that my
client is going to have several PDAs for several employees, and
everyone of them should be able to use any of the PDAs, logon against
a LAN server and get their privileges, mapped connections and so on,
just as if they were to logon on a network-connected computer. If you
think of *ANY* way of doing this, please tell me.

One last thing: I hope you'll know to excuse the tone of this post.
I'm not angry (and of course I'm not angry *with you*; in fact I'm
really grateful to have someone to talk to about this), I'm
frustrated. Again, please excuse my tone if you found it offensive.


Thanks again for being there, Paul.

Regards,
Carlos


"Paul G. Tobey [eMVP]" <ptobey_no_spam@instrument_no_spam.com> wrote in
message news: said:
I didn't think that the NETUI component had an publicly-documented API, but
I can find at least one of the functions exported by it,
GetUsernamePassword(), in the CE.NET 4.2 documentation. In my version of
the help, it's in the Application Development section, under Network User
Interface. I'm using, essentially, the Platform Builder help, so maybe that
explains why you can't find anything. You should be able to download an
evaluation version of PB from the Microsoft Web site...

Paul T.
 
Huh? Can you provide samples of when the SDK roller gets something wrong?
Let's be clear on what it is supposed to do. The SDK roller gets the header
and library files from the platforms CESYSGEN\SDK folder. No more no less.
Then you have the OPTION of including ATL, MFC, CF support and any other
headers you desire.

It is NOT supposed to automatically pull in any of the unfiltered headers or
libs nor the filtered OAK or DDK ones. If you desire any of those in your
SDK you need to manually add it. (and you should think about whether they
really are necessary as you will end up supporting them with developers who
don't understand how to use them properly!)
 
Well, in this case, for example, it's reasonable to include netui.h, but it
doesn't unless you force it manually. It's not wrong, necessarily, but we
*do* frequently tell people that they need to get header file X from the OEM
or from PB, and the number of times we do that is a rough measure of the
effectiveness of the 'unfiltered' header list. There are about 15 messages
popped up when you search on "missing header file evaluation", 15 more for
"missing header oem", 30 for "missing .h oem", and 20 for "missing .h
evaluation". It happens.

Supporting developers who don't know how to use stuff properly is always a
problem! In this case, there's just two layers of problems: getting the
header file, and then using it, rather than just using it.

Paul T.
 
OK, I'd agree there are some headers etc... that are standard in the OAK
that are pretty darn useful to developers and ought to go into the SDK. I
was wondering if there was some other issue you had encountered. As that's
not so much a problem with the SDK roller. As it is a design choice on the
part of MS. Given the numbers you've quoted it seems a significant enough
issue to try to lobby for some change in a future release.
 
I haven't run into something where feature A from the catalog is in the OS,
but the header for it isn't, as far as I can recall, no. You're right; I
blamed the wrong 'person'.

Paul T.
 
Paul G. Tobey said:
I haven't run into something where feature A from the catalog is in the OS,
but the header for it isn't, as far as I can recall, no. You're right; I
blamed the wrong 'person'.

Paul T.


Thanks for the info, Paul. After all, I managed to download and
(almost, because one of the CABs was corrupted) install the CE .NET
SDK and Platform Builder, and I got access to the netui.h file. HEre's
the code I've managed to write:

// SavePwd box is checked
private const int NETUI_USERPWD_SAVEPWD = 0x00000001;
// Show the SavePwd control
private const int NETUI_USERPWD_SHOW_SAVEPWD = 0x00000002;
// Connecting to network server
private const int NETUI_USERPWD_SERVERLOGON = 0x00000004;

[StructLayout(LayoutKind.Sequential)]
private struct NETUI_USERPWD
{
public string szUserName;
public string szPassword;
public string szDomain;
public int dwFlags;
public string szResourceName;
}

[DllImport("netui.dll")]
static extern bool GetUsernamePassword(IntPtr hParent,
ref NETUI_USERPWD pUserPwd);


//And this is the calling:

//Other P/Invoking to capture the handle of the calling form
//This code, not being mine, WORKS OK
IntPtr hW = GetHWnd(baseForm);
//And here I try to launch the dialog
NETUI_USERPWD stDatos = new NETUI_USERPWD();
stDatos.dwFlags = NETUI_USERPWD_SERVERLOGON;
return GetUsernamePassword(hW, ref stDatos);

There must be something wrong with my p/invoking, because I'm
constantly getting the dreaded System.NotSupportedException, no matter
what I try. Could you please be so kind as of revising this code and
hint what's wrong? Thank you so much.

And by the way, this happens to be the first time I have to work with
the compact framework, and also it's the first time I have to work
with unmanaged code, and I'm not specially proficient at C++. It's a
lot of first-timers to get everything working smoothly, so I thank all
help, no matter where it comes from. Some people seem to lack the need
for help from time to time, and they seem to despise the ones that do
need help sometimes. Good for them, I guess. But WAY BETTER for the
people that help others in need.

Regards,
Carlos
 
I think that the problem is your declaration of the structure. You can't
just declare those items as strings. A string is going to be a reference to
a heap-allocated object in CF. You need to make it an array of Unicode
characters, stored right there in the structure, instead. This is done
quite a bit in OpenNETCF and you can use the MarshalEx class to help you get
it right. I think that's the problem, though.

Paul T.

Carlos M Perez said:
"Paul G. Tobey [eMVP]" <ptobey_no_spam@instrument_no_spam.com> wrote in
message news: said:
I haven't run into something where feature A from the catalog is in the OS,
but the header for it isn't, as far as I can recall, no. You're right; I
blamed the wrong 'person'.

Paul T.


Thanks for the info, Paul. After all, I managed to download and
(almost, because one of the CABs was corrupted) install the CE .NET
SDK and Platform Builder, and I got access to the netui.h file. HEre's
the code I've managed to write:

// SavePwd box is checked
private const int NETUI_USERPWD_SAVEPWD = 0x00000001;
// Show the SavePwd control
private const int NETUI_USERPWD_SHOW_SAVEPWD = 0x00000002;
// Connecting to network server
private const int NETUI_USERPWD_SERVERLOGON = 0x00000004;

[StructLayout(LayoutKind.Sequential)]
private struct NETUI_USERPWD
{
public string szUserName;
public string szPassword;
public string szDomain;
public int dwFlags;
public string szResourceName;
}

[DllImport("netui.dll")]
static extern bool GetUsernamePassword(IntPtr hParent,
ref NETUI_USERPWD pUserPwd);


//And this is the calling:

//Other P/Invoking to capture the handle of the calling form
//This code, not being mine, WORKS OK
IntPtr hW = GetHWnd(baseForm);
//And here I try to launch the dialog
NETUI_USERPWD stDatos = new NETUI_USERPWD();
stDatos.dwFlags = NETUI_USERPWD_SERVERLOGON;
return GetUsernamePassword(hW, ref stDatos);

There must be something wrong with my p/invoking, because I'm
constantly getting the dreaded System.NotSupportedException, no matter
what I try. Could you please be so kind as of revising this code and
hint what's wrong? Thank you so much.

And by the way, this happens to be the first time I have to work with
the compact framework, and also it's the first time I have to work
with unmanaged code, and I'm not specially proficient at C++. It's a
lot of first-timers to get everything working smoothly, so I thank all
help, no matter where it comes from. Some people seem to lack the need
for help from time to time, and they seem to despise the ones that do
need help sometimes. Good for them, I guess. But WAY BETTER for the
people that help others in need.

Regards,
Carlos
 

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

Back
Top