version 1.68, 2006/10/31 19:47:32
|
version 1.70, 2006/11/10 18:14:58
|
|
|
userId.append(Char16(userName[i])); | userId.append(Char16(userName[i])); |
} | } |
| |
} else |
} |
|
else |
{ | { |
//userId.append(userName); | //userId.append(userName); |
Uint32 n = wcslen(userName); | Uint32 n = wcslen(userName); |
|
|
userId.append(Char16(pUserName[i])); | userId.append(Char16(pUserName[i])); |
} | } |
| |
|
|
return userId; | return userId; |
#endif | #endif |
} | } |
|
|
LPUSER_INFO_1 pUserInfo = NULL; | LPUSER_INFO_1 pUserInfo = NULL; |
NET_API_STATUS nStatus = NULL; | NET_API_STATUS nStatus = NULL; |
| |
// Make a copy of the specified username, it cannot be used directly because it's |
// Make a copy of the specified username, it cannot be used directly |
// declared as const and strchr() may modify the string. |
// because it's declared as const and strchr() may modify the string. |
strncpy(tUserName, userName, sizeof(tUserName) - 1); | strncpy(tUserName, userName, sizeof(tUserName) - 1); |
tUserName[sizeof(tUserName)- 1] = '\0'; | tUserName[sizeof(tUserName)- 1] = '\0'; |
| |
|
|
strcpy(mUserName, pbs+1); | strcpy(mUserName, pbs+1); |
usingDomain = true; | usingDomain = true; |
| |
} else if ((NULL != (pbs = (strchr(tUserName, '@')))) || |
} |
|
else if ((NULL != (pbs = (strchr(tUserName, '@')))) || |
(NULL != (pbs = (strchr(tUserName, '.'))))) | (NULL != (pbs = (strchr(tUserName, '.'))))) |
{ | { |
*pbs = '\0'; | *pbs = '\0'; |
|
|
strcpy(mUserName, tUserName); | strcpy(mUserName, tUserName); |
usingDomain = true; | usingDomain = true; |
| |
} else |
} |
|
else |
{ | { |
strcpy(mDomainName, "."); | strcpy(mDomainName, "."); |
strcpy(mUserName, tUserName); | strcpy(mUserName, tUserName); |
} | } |
| |
//convert domain name to unicode | //convert domain name to unicode |
if (!MultiByteToWideChar(CP_ACP, 0, mDomainName, -1, wDomainName, strlen(mDomainName)+1)) |
if (!MultiByteToWideChar( |
|
CP_ACP, 0, mDomainName, -1, wDomainName, strlen(mDomainName) + 1)) |
{ | { |
return false; | return false; |
} | } |
| |
//convert username to unicode | //convert username to unicode |
if (!MultiByteToWideChar(CP_ACP, 0, mUserName, -1, wUserName, strlen(mUserName)+1)) |
if (!MultiByteToWideChar( |
|
CP_ACP, 0, mUserName, -1, wUserName, strlen(mUserName) + 1)) |
{ | { |
return false; | return false; |
} | } |
|
|
DWORD rc = NetGetDCName(NULL, wDomainName, &pComputerName); | DWORD rc = NetGetDCName(NULL, wDomainName, &pComputerName); |
if (rc == NERR_Success) | if (rc == NERR_Success) |
{ | { |
wcscpy(wDomainName, (LPWSTR) pComputerName); //this is automatically prefixed with "\\" |
// this is automatically prefixed with "\\" |
|
wcscpy(wDomainName, (LPWSTR) pComputerName); |
} | } |
/* | /* |
else | else |
{ | { |
// failover | // failover |
// ATTN: This is commented out until there is resolution on Bugzilla 2236. -hns 2/2005 |
// ATTN: This is commented out until there is resolution on |
|
// Bugzilla 2236. -hns 2/2005 |
// This needs to be more thoroughly tested when we uncomment it out. | // This needs to be more thoroughly tested when we uncomment it out. |
| |
PDOMAIN_CONTROLLER_INFO DomainControllerInfo = NULL; | PDOMAIN_CONTROLLER_INFO DomainControllerInfo = NULL; |
|
|
mDomainName, | mDomainName, |
NULL, | NULL, |
NULL, | NULL, |
DS_DIRECTORY_SERVICE_REQUIRED, //not sure what flags we want here |
//not sure what flags we want here |
|
DS_DIRECTORY_SERVICE_REQUIRED, |
&DomainControllerInfo); | &DomainControllerInfo); |
| |
if (rc == ERROR_SUCCESS && DomainControllerInfo) | if (rc == ERROR_SUCCESS && DomainControllerInfo) |
|
|
strcpy(mDomainName, DomainControllerInfo->DomainName); | strcpy(mDomainName, DomainControllerInfo->DomainName); |
NetApiBufferFree(DomainControllerInfo); | NetApiBufferFree(DomainControllerInfo); |
| |
if (!MultiByteToWideChar(CP_ACP, 0, mDomainName, -1, wDomainName, strlen(mDomainName)+1)) |
if (!MultiByteToWideChar( |
|
CP_ACP, 0, mDomainName, -1, wDomainName, |
|
strlen(mDomainName) + 1)) |
{ | { |
return false; | return false; |
} | } |
|
|
strcpy(mUserName, pbs+1); | strcpy(mUserName, pbs+1); |
usingDomain = true; | usingDomain = true; |
| |
} else if ((NULL != (pbs = (strchr(userStr, '@')))) || |
} |
|
else if ((NULL != (pbs = (strchr(userStr, '@')))) || |
(NULL != (pbs = (strchr(userStr, '.'))))) | (NULL != (pbs = (strchr(userStr, '.'))))) |
{ | { |
*pbs = '\0'; | *pbs = '\0'; |
|
|
strcpy(mUserName, userStr); | strcpy(mUserName, userStr); |
usingDomain = true; | usingDomain = true; |
| |
} else |
} |
|
else |
{ | { |
strcpy(mDomainName, "."); | strcpy(mDomainName, "."); |
strcpy(mUserName, userStr); | strcpy(mUserName, userStr); |
} | } |
| |
//convert domain name to unicode | //convert domain name to unicode |
if (!MultiByteToWideChar(CP_ACP, 0, mDomainName, -1, wDomainName, strlen(mDomainName)+1)) |
if (!MultiByteToWideChar( |
|
CP_ACP, 0, mDomainName, -1, wDomainName, strlen(mDomainName) + 1)) |
{ | { |
return false; | return false; |
} | } |
| |
//convert username to unicode | //convert username to unicode |
if (!MultiByteToWideChar(CP_ACP, 0, mUserName, -1, wUserName, strlen(mUserName)+1)) |
if (!MultiByteToWideChar( |
|
CP_ACP, 0, mUserName, -1, wUserName, strlen(mUserName) + 1)) |
{ | { |
return false; | return false; |
} | } |
|
|
DWORD rc = NetGetDCName(NULL, wDomainName, &pComputerName); | DWORD rc = NetGetDCName(NULL, wDomainName, &pComputerName); |
if (rc == NERR_Success) | if (rc == NERR_Success) |
{ | { |
wcscpy(wDomainName, (LPWSTR) pComputerName); //this is automatically prefixed with "\\" |
// this is automatically prefixed with "\\" |
|
wcscpy(wDomainName, (LPWSTR) pComputerName); |
} | } |
/* | /* |
else | else |
{ | { |
// failover | // failover |
// ATTN: This is commented out until there is resolution on Bugzilla 2236. -hns 2/2005 |
// ATTN: This is commented out until there is resolution on |
|
// Bugzilla 2236. -hns 2/2005 |
// This needs to be more thoroughly tested when we uncomment it out. | // This needs to be more thoroughly tested when we uncomment it out. |
| |
PDOMAIN_CONTROLLER_INFO DomainControllerInfo = NULL; | PDOMAIN_CONTROLLER_INFO DomainControllerInfo = NULL; |
|
|
mDomainName, | mDomainName, |
NULL, | NULL, |
NULL, | NULL, |
DS_DIRECTORY_SERVICE_REQUIRED, //not sure what flags we want here |
// not sure what flags we want here |
|
DS_DIRECTORY_SERVICE_REQUIRED, |
&DomainControllerInfo); | &DomainControllerInfo); |
| |
if (rc == ERROR_SUCCESS && DomainControllerInfo) | if (rc == ERROR_SUCCESS && DomainControllerInfo) |
|
|
strcpy(mDomainName, DomainControllerInfo->DomainName); | strcpy(mDomainName, DomainControllerInfo->DomainName); |
NetApiBufferFree(DomainControllerInfo); | NetApiBufferFree(DomainControllerInfo); |
| |
if (!MultiByteToWideChar(CP_ACP, 0, mDomainName, -1, wDomainName, strlen(mDomainName)+1)) |
if (!MultiByteToWideChar( |
|
CP_ACP, 0, mDomainName, -1, wDomainName, |
|
strlen(mDomainName) + 1)) |
{ | { |
return false; | return false; |
} | } |
|
|
// ATTN-NB-03-20000304: Implement better way to get the privileged | // ATTN-NB-03-20000304: Implement better way to get the privileged |
// user on the system. | // user on the system. |
| |
return (String("Administrator")); |
return String("Administrator"); |
} | } |
| |
Boolean System::isGroupMember(const char* userName, const char* groupName) | Boolean System::isGroupMember(const char* userName, const char* groupName) |
|
|
if (*p == '/') | if (*p == '/') |
*p = '\\'; | *p = '\\'; |
| |
return (strcasecmp(_fullpath( full, path_slash, _MAX_PATH ), path_slash) == 0) ? true : false; |
return (strcasecmp( |
|
_fullpath(full, path_slash, _MAX_PATH), path_slash) == 0); |
} | } |
| |
// Changes file permissions on the given file. | // Changes file permissions on the given file. |
|
|
// Not implemented | // Not implemented |
} | } |
| |
|
void System::openlog(const char *ident, int logopt, int facility) |
|
{ |
|
// Not implemented |
|
} |
|
|
|
void System::closelog() |
|
{ |
|
// Not implemented |
|
} |
|
|
|
|
|
|
// System ID constants for Logger::put and Logger::trace | // System ID constants for Logger::put and Logger::trace |
const String System::CIMSERVER = "cimserver"; // Server system ID | const String System::CIMSERVER = "cimserver"; // Server system ID |
| |
|
|
{ | { |
free(output_buf); | free(output_buf); |
closesocket(sock); | closesocket(sock); |
return(true); |
return true; |
|
} |
} | } |
} | } |
} else { |
else |
|
{ |
free(output_buf); | free(output_buf); |
return false; | return false; |
} | } |