Solved

Syntax for WNetCachePassword() and WNetGetCachedPassword()

Posted on 1999-01-07
7
221 Views
Last Modified: 2013-12-03
Does anybody know the prototypes for WNetCachePassword() and WNetGetCachedPassword() for Windows 95? They are undocumented functions exported by mpr.dll for modifying .PWL files.
0
Comment
Question by:eppsman
  • 4
  • 3
7 Comments
 
LVL 17

Expert Comment

by:inthe
ID: 1418307
hi ,
is this of any help ,Here are two functions for setting/getting a netware password in the pwl file:

CString CNovell::GetPwd(CString szServer)
{
      char pbPassword[100];
      LPSTR p;
      DWORD ret;
      WORD cbPassword = sizeof(pbPassword);
      
      ret = WNetGetCachedPassword((LPSTR)(LPCSTR) szServer,
szServer.GetLength(), pbPassword, &cbPassword, (BYTE)18);
      if (ret == 0) {
            try {
                  p = pbPassword;
                  p += (strlen(pbPassword) +1);
                  return (p);
            }catch(...) {
                  return "";
            }
      }
      else
            return "";
}

void CNovell::SetPwd(LPBYTE lpDataSites)
{
      DWORD cbUserPwd;
      ULONG dwRet;
      LPSTR lpUserID, lpPwd,p, lpServer;
      LPSTR lpUserPwd = new char[1000];
      LPSITEDATA pDataSites;
      pDataSites = (LPSITEDATA) lpDataSites;
      CString szBuf;
      pDataSites->NovellUserID.TrimRight();
      //pDataSites->NovellServer.TrimRight();
      pDataSites->NovellRemoteDevice.TrimRight();
      pDataSites->NovellPassword.TrimRight();

      if (pDataSites->NovellPassword == "")
            return;

      // extract novell server from the remote path
      try {
            szBuf = pDataSites->NovellRemoteDevice;
            szBuf = szBuf.Mid(2); // skip "\\"
            szBuf = szBuf.Left(szBuf.Find("\\"));
            lpServer = (LPSTR)(LPCSTR)szBuf;
      }
      catch(...){
            return;
      }

      //lpServer = (LPSTR)(LPCSTR)pDataSites->NovellServer;
      lpPwd = (LPSTR)(LPCSTR)pDataSites->NovellPassword;
      lpUserID = (LPSTR)(LPCSTR)pDataSites->NovellUserID;

      strcpy(lpUserPwd, lpUserID);
      strcat(lpUserPwd, " ");
      strcat(lpUserPwd, lpPwd);
      cbUserPwd = strlen(lpUserPwd);
      p=strstr(lpUserPwd, " ");
      if (p)
            *p=0;
      else {
            delete lpUserPwd;
            return;
      }

      dwRet = WNetRemoveCachedPassword(lpServer, strlen(lpServer), (BYTE)18);
      dwRet = WNetCachePassword(lpServer, strlen(lpServer),
                        lpUserPwd, cbUserPwd, (BYTE) 18, 0);

      delete lpUserPwd;
Regards Barry

0
 

Author Comment

by:eppsman
ID: 1418308
What is the meaning of the 18 sent to the functions? Is this just a unique identifier? What does the final 0 do for WNetCachePassword()? If you can tell me these things, you can propose it as an answer, and I'll give it grade A. Thanks!
0
 
LVL 17

Accepted Solution

by:
inthe earned 50 total points
ID: 1418309
hi,
(#define CPW_MEMORYONLY  0x01 First for fnFlags)
The  0 is for fnFlags(final parameter) if you want the password stored permanently in the cache.
Use 1 if you want password kept only for the duration of the login.
The nType(18) is the type of password resource. Type 18 means a netware account and password.

WNetCachePassword(LPCSTR pbResource,
                  WORD  cbResource,
                  LPCSTR pbPassword,
                  WORD  cbPassword,
                  BYTE  nType,
                  UINT  fnFlags);

WNetGetCachedPassword(LPCSTR  pbResource,
                      WORD   cbResource,
                      LPSTR  pbPassword,
                      LPWORD pcbPassword,
                      BYTE   nType);

Regards Barry

0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:eppsman
ID: 1418310
What other types besides NetWare are available?
Also, do you have the prototype for WNetRemoveCachedPassword()?
If you do, I will adjust the points, since that was not part of the original question.

Thanks in advance.

0
 

Author Comment

by:eppsman
ID: 1418311
Oh, I can see the prototype for WNetRemoveCachedPassword on your first code sample - never mind that. I would still like to know what other password types besides NetWare are available. Thanks.
0
 
LVL 17

Expert Comment

by:inthe
ID: 1418312
I wish i could tell you more but sorry everything above was all i had on the subject and i tried win95 ddk on msdn but it's not there anymore or at least the texts that used to be there are'nt :-(
i also scanned net and newsgroups and could find nothing we dont already know .it seems to be one subject that is hard to get info about i thought being unsupported there would be plenty of people talking bout it on the net somewhere .

this quoted text below is is all i could get that may be of assistance :

"You need to get hold of the win 95 ddk, in their you will find netmpr.h header file which will show the cached headers. DDK will also give you some brief descriptions of the functions."

hope you find what you need
Regards Barry
0
 

Author Comment

by:eppsman
ID: 1418313
I'll check that out. Thanks.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article shows how to make a Windows 7 gadget that accepts files dropped from the Windows Explorer.  It also illustrates how to give your gadget a non-rectangular shape and how to add some nifty visual effects to text displayed in a your gadget.…
This article surveys and compares options for encoding and decoding base64 data.  It includes source code in C++ as well as examples of how to use standard Windows API functions for these tasks. We'll look at the algorithms — how encoding and decodi…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now