Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

0 lines
39 KiB

  1. // =========================================================================== // UAMNetwork.c � 1998-2001 Microsoft Corp. All rights reserved. // =========================================================================== // Networking functions for use by Microsoft User Authentication Method. // // There are several versions of authentication used by the UAM to an SFM // server. Here is the matrix which shows which Microsoft AFP encryption // version will be used depending on the server version. // // Server Version Auth Chng Pswd Notes // -------------- ---- --------- --------------- // NT 4.0 1.0 1.0 Weakest, LM Hash only // Win2K 2.0 2.0 NTLMv2 auth, LM Hash for chgn pswd // .NET 2.0 3.0 Strongest, using NTLMv2 for both // // =========================================================================== #ifdef UAM_TARGET_CARBON #include <CoreFoundation/CoreFoundation.h> #include <Carbon/Carbon.h> #endif #include <macssp.h> #include <String.h> #include <macstrsafe.h> #include "UAMMain.h" #include "UAMEncrypt.h" #include "UAMDebug.h" #include "UAMNetwork.h" #include "UAMUtils.h" #include "UAMDLOGUtils.h" #include "UAMDialogs.h" #include "UAMKeychain.h" #include "UAMPrefs.h" unsigned char gCmdBuffer[kMaxAFPCommand]; unsigned char gReplyBuffer[kMaxAFPCommand]; MSUAMLoginReplyBlock gMSUAMReply; extern Str32 gAFPVersion; extern OTAddress *gServerAddress; extern long gSupportedUAMs; extern UInt32 gExpirationTime; extern Str32 gServerName; extern Boolean gGuestLogon; extern DialogPtr gDialog; extern UAM_PREFERENCES gUAMPreferences; // --------------------------------------------------------------------------- // � UAM_MapCharactersIntoHostSet() // --------------------------------------------------------------------------- // Given a counted string, and a "host mapping table", do an in-place conversion // of that string into the host character set. The table is construed to be // of length 255 - StartingExtendedCharValue chars long, and a character for // character conversion will be indicated for any chars in targetStr which // are equal to or in excess of StartingExtendedCharValue. Boolean UAM_MapCharactersIntoHostSet(char *szTarg, char *mappingTbl) { unsigned char c; while (*szTarg) { if ((unsigned char)*szTarg >= (unsigned char)kStartingExtendedCharValue) { c = *(mappingTbl+ (unsigned char)*szTarg - kStartingExtendedCharValue); if (c == kIllegalMappedExtChar) { DbgPrint_((DBGBUFF, "Illegal mapping character")); return(false); } else { *szTarg = c; } } szTarg++; } return(true); } #pragma mark- // --------------------------------------------------------------------------- // � UAM_UAMLogin() // --------------------------------------------------------------------------- // This routine does the actual logging onto the server. OSStatus UAM_UAMLogin(UAMArgs *inUAMArgs) { OSStatus theError = noErr; Boolean theLoop = true; CursHandle theCursor; Assert_(inUAMArgs != NULL); do { theCursor = GetCursor(watchCursor); SetCursor(*theCursor); if (gGuestLogon) { theError = UAM_LoginGuest(inUAMArgs); } else { SspDebugPrintHex( (char*)inUAMArgs->Opt.pwDlg.userName, PSTR_LENGTH(inUAMArgs->Opt.pwDlg.userName)+1 ); SspDebugPrintHex( (char*)inUAMArgs->Opt.pwDlg.password, strlen((char*)inUAMArgs->Opt.pwDlg.password) ); // //The password buffer in UAMArgs is always in C style form. The encryption //routines expect it to be in pascal style, so we convert it before we //send it on. // if (strlen((char*)inUAMArgs->Opt.pwDlg.password) != 0) { _c2pstr((char*)inUAMArgs->Opt.pwDlg.password); } theError = UAM_LoginMSUAM(inUAMArgs); } if (theError != noErr) { // //For whatever reason, we couldn't log into the server, handle the most //basic errors and try to logon again by presenting the login dialog //again.