1 /* 2 * COPYRIGHT: See COPYING in the top level directory 3 * PROJECT: Local Security Authority (LSA) Server 4 * FILE: reactos/dll/win32/lsasrv/dssetup.c 5 * PURPOSE: Directory Service setup functions 6 * 7 * PROGRAMMERS: Eric Kohl 8 */ 9 10 #include "lsasrv.h" 11 #include "dssetup_s.h" 12 #include "resources.h" 13 14 VOID 15 NTAPI 16 LsaIFree_LSAPR_POLICY_INFORMATION(IN POLICY_INFORMATION_CLASS InformationClass, 17 IN PLSAPR_POLICY_INFORMATION PolicyInformation); 18 19 /* GLOBALS *****************************************************************/ 20 21 VOID 22 DsSetupInit(VOID) 23 { 24 RPC_STATUS Status; 25 26 Status = RpcServerRegisterIf(dssetup_v0_0_s_ifspec, 27 NULL, 28 NULL); 29 if (Status != RPC_S_OK) 30 { 31 WARN("RpcServerRegisterIf() failed (Status %lx)\n", Status); 32 return; 33 } 34 } 35 36 37 static 38 NET_API_STATUS 39 DsRolepGetBasicInfo( 40 PDSROLER_PRIMARY_DOMAIN_INFORMATION *DomainInfo) 41 { 42 LSAPR_OBJECT_ATTRIBUTES ObjectAttributes; 43 PDSROLER_PRIMARY_DOMAIN_INFO_BASIC Buffer; 44 PLSAPR_POLICY_INFORMATION PolicyInfo; 45 LSA_HANDLE PolicyHandle; 46 ULONG Size; 47 NTSTATUS Status; 48 49 RtlZeroMemory(&ObjectAttributes, sizeof(ObjectAttributes)); 50 Status = LsarOpenPolicy(NULL, 51 &ObjectAttributes, 52 POLICY_VIEW_LOCAL_INFORMATION, 53 &PolicyHandle); 54 if (!NT_SUCCESS(Status)) 55 { 56 TRACE("LsarOpenPolicyFailed with NT status %x\n", 57 LsaNtStatusToWinError(Status)); 58 return ERROR_OUTOFMEMORY; 59 } 60 61 Status = LsarQueryInformationPolicy(PolicyHandle, 62 PolicyAccountDomainInformation, 63 &PolicyInfo); 64 LsarClose(&PolicyHandle); 65 if (!NT_SUCCESS(Status)) 66 { 67 TRACE("LsarQueryInformationPolicy with NT status %x\n", 68 LsaNtStatusToWinError(Status)); 69 return ERROR_OUTOFMEMORY; 70 } 71 72 Size = sizeof(DSROLER_PRIMARY_DOMAIN_INFO_BASIC) + 73 PolicyInfo->PolicyAccountDomainInfo.DomainName.Length + sizeof(WCHAR); 74 75 Buffer = midl_user_allocate(Size); 76 if (Buffer == NULL) 77 { 78 LsaIFree_LSAPR_POLICY_INFORMATION(PolicyAccountDomainInformation, 79 PolicyInfo); 80 return ERROR_OUTOFMEMORY; 81 } 82 83 Buffer->MachineRole = DsRole_RoleStandaloneWorkstation; 84 Buffer->DomainNameFlat = (LPWSTR)((LPBYTE)Buffer + 85 sizeof(DSROLER_PRIMARY_DOMAIN_INFO_BASIC)); 86 wcscpy(Buffer->DomainNameFlat, PolicyInfo->PolicyAccountDomainInfo.DomainName.Buffer); 87 88 LsaIFree_LSAPR_POLICY_INFORMATION(PolicyAccountDomainInformation, 89 PolicyInfo); 90 91 *DomainInfo = (PDSROLER_PRIMARY_DOMAIN_INFORMATION)Buffer; 92 93 return ERROR_SUCCESS; 94 } 95 96 97 static 98 NET_API_STATUS 99 DsRolepGetUpdateStatus( 100 PDSROLER_PRIMARY_DOMAIN_INFORMATION *DomainInfo) 101 { 102 PDSROLE_UPGRADE_STATUS_INFO Buffer; 103 104 Buffer = midl_user_allocate(sizeof(DSROLE_UPGRADE_STATUS_INFO)); 105 if (Buffer == NULL) 106 return ERROR_OUTOFMEMORY; 107 108 Buffer->OperationState = 0; 109 Buffer->PreviousServerState = 0; 110 111 *DomainInfo = (PDSROLER_PRIMARY_DOMAIN_INFORMATION)Buffer; 112 113 return ERROR_SUCCESS; 114 } 115 116 117 static 118 NET_API_STATUS 119 DsRolepGetOperationState( 120 PDSROLER_PRIMARY_DOMAIN_INFORMATION *DomainInfo) 121 { 122 PDSROLE_OPERATION_STATE_INFO Buffer; 123 124 Buffer = midl_user_allocate(sizeof(DSROLE_OPERATION_STATE_INFO)); 125 if (Buffer == NULL) 126 return ERROR_OUTOFMEMORY; 127 128 Buffer->OperationState = DsRoleOperationIdle; 129 130 *DomainInfo = (PDSROLER_PRIMARY_DOMAIN_INFORMATION)Buffer; 131 132 return ERROR_SUCCESS; 133 } 134 135 136 DWORD 137 WINAPI 138 DsRolerGetPrimaryDomainInformation( 139 handle_t hBinding, 140 DSROLE_PRIMARY_DOMAIN_INFO_LEVEL InfoLevel, 141 PDSROLER_PRIMARY_DOMAIN_INFORMATION *DomainInfo) 142 { 143 NET_API_STATUS ret; 144 145 TRACE("DsRolerGetPrimaryDomainInformation(%p, %d, %p)\n", 146 hBinding, InfoLevel, DomainInfo); 147 148 switch (InfoLevel) 149 { 150 case DsRolePrimaryDomainInfoBasic: 151 ret = DsRolepGetBasicInfo(DomainInfo); 152 break; 153 154 case DsRoleUpgradeStatus: 155 ret = DsRolepGetUpdateStatus(DomainInfo); 156 break; 157 158 case DsRoleOperationState: 159 ret = DsRolepGetOperationState(DomainInfo); 160 break; 161 162 default: 163 ret = ERROR_CALL_NOT_IMPLEMENTED; 164 } 165 166 return ret; 167 } 168 169 /* EOF */ 170