NTSTATUS LsapInitLsa( ) /*++ Routine Description: This process is activated as a standard SM subsystem. Initialization completion of a SM subsystem is indicated by having the first thread exit with status. This function initializes the LSA. The initialization procedure comprises the following steps: o LSA Heap Initialization o LSA Command Server Initialization o LSA Database Load o Reference Monitor State Initialization o LSA RPC Server Initialization o LSA Auditing Initialization o LSA Authentication Services Initialization o Wait for Setup to complete (if necessary) o LSA database initialization (product type-specific) Any failure in any of the above steps is fatal and causes the LSA process to terminate. The system must be aborted. Arguments: None. Return Value: NTSTATUS - Standard Nt Result Code. --*/ { NTSTATUS Status; BOOLEAN BooleanStatus = TRUE; BOOLEAN AuditingInitPass1Success = TRUE; // // Initialize the LSA's heap. // Status = LsapHeapInitialize(); if (!NT_SUCCESS(Status)) { goto InitLsaError; } // // Initialize a copy of the Well-Known Sids, etc. for use by // the LSA. // Status = LsapDbInitializeWellKnownValues(); if (!NT_SUCCESS(Status)) { goto InitLsaError; } // // Perform LSA Command Server Initialization. This involves creating // an LPC port called the LSA Command Server Port so that the Reference // monitor can send commands to the LSA via the port. After the port // is created, an event created by the Reference Monitor is signalled, // so that the Reference Monitor can proceed to connect to the port. Status = LsapRmInitializeServer(); if (!NT_SUCCESS(Status)) { goto InitLsaError; } // // Disable Replicator Notifications. // LsapDbDisableReplicatorNotification(); // // Perform LSA Database Server Initialization - Pass 1. // This initializes the non-product-type-specific information. // Status = LsapDbInitializeServer(1); if (!NT_SUCCESS(Status)) { goto InitLsaError; } // // Perform RPC Server Initialization. // Status = LsapRPCInit(); if (!NT_SUCCESS(Status)) { goto InitLsaError; } // // Perform Auditing Initialization - Pass 1. // LsapAdtInitializationPass = 1; Status = LsapAdtInitialize(LsapAdtInitializationPass); if (!NT_SUCCESS(Status)) { AuditingInitPass1Success = FALSE; Status = STATUS_SUCCESS; } Status = LsapAdtObjsInitialize(); ASSERT( NT_SUCCESS( Status )); // // Initialize Authentication Services // if (!LsapAuInit()) { Status = STATUS_UNSUCCESSFUL; goto InitLsaError; } /* Status = LsapAuInit(); if (!NT_SUCCESS(Status)) { goto InitLsaError; } */ // // Start processing RPC calls // Status = LsapActivateRpcServer(); if (!NT_SUCCESS(Status)) { goto InitLsaError; } // // Pause for installation if necessary // Status = LsapInstallationPause(); if (!NT_SUCCESS(Status)) { goto InitLsaError; } // // Perform LSA Database Server Initialization - Pass 2. // This initializes the product-type-specific information. // LsapAdtInitializationPass = 2; Status = LsapDbInitializeServer(LsapAdtInitializationPass); if (!NT_SUCCESS(Status)) { goto InitLsaError; } // // Enable Replicator Notifications. // LsapDbEnableReplicatorNotification(); // // Perform Auditing Initialization - Pass 2. // This pass writes out any remaining cached Audit Records collected during // initialization. // if (AuditingInitPass1Success) { Status = LsapAdtInitialize(2); if (!NT_SUCCESS(Status)) { Status = STATUS_SUCCESS; } } // // Enable health checking within lsa // LsaIHealthCheck( LsaIHealthLsaInitialized ); InitLsaFinish: return(Status); InitLsaError: goto InitLsaFinish; }
NTSTATUS WINAPI LsapInitLsa(VOID) { HANDLE hEvent; DWORD dwError; NTSTATUS Status; TRACE("LsapInitLsa() called\n"); /* Initialize the well known SIDs */ LsapInitSids(); /* Initialize the SRM server */ Status = LsapRmInitializeServer(); if (!NT_SUCCESS(Status)) { ERR("LsapRmInitializeServer() failed (Status 0x%08lx)\n", Status); return Status; } /* Initialize the LSA database */ LsapInitDatabase(); /* Initialize logon sessions */ LsapInitLogonSessions(); /* Initialize registered authentication packages */ Status = LsapInitAuthPackages(); if (!NT_SUCCESS(Status)) { ERR("LsapInitAuthPackages() failed (Status 0x%08lx)\n", Status); return Status; } /* Start the authentication port thread */ Status = StartAuthenticationPort(); if (!NT_SUCCESS(Status)) { ERR("StartAuthenticationPort() failed (Status 0x%08lx)\n", Status); return Status; } /* Start the RPC server */ LsarStartRpcServer(); TRACE("Creating notification event!\n"); /* Notify the service manager */ hEvent = CreateEventW(NULL, TRUE, FALSE, L"LSA_RPC_SERVER_ACTIVE"); if (hEvent == NULL) { dwError = GetLastError(); TRACE("Failed to create the notication event (Error %lu)\n", dwError); if (dwError == ERROR_ALREADY_EXISTS) { hEvent = OpenEventW(GENERIC_WRITE, FALSE, L"LSA_RPC_SERVER_ACTIVE"); if (hEvent == NULL) { ERR("Could not open the notification event (Error %lu)\n", GetLastError()); return STATUS_UNSUCCESSFUL; } } } TRACE("Set notification event!\n"); SetEvent(hEvent); /* NOTE: Do not close the event handle!!!! */ return STATUS_SUCCESS; }