non-ad-afs-profile-20040819

NetUserGetProfilePath function provided by Rolandas Naujikas
This commit is contained in:
Rolandas Naujikas 2004-08-19 20:47:56 +00:00 committed by Jeffrey Altman
parent 481b170d88
commit f2b18e7af8

View File

@ -14,7 +14,8 @@
#include <sys/types.h>
#include <fcntl.h>
#include <winsock2.h>
#include <winsock2.h> ]
#include <lm.h>
#include <afs/param.h>
#include <afs/stds.h>
@ -58,7 +59,7 @@ void DebugEvent(char *b,...)
StringCbVPrintf(buf, MAXBUF_+1,b,marker);
buf[MAXBUF_] = '\0';
ptbuf[0] = buf;
ReportEvent(h, EVENTLOG_INFORMATION_TYPE, 0, 0, NULL, 1, 0, (const char **)ptbuf, NULL);\
ReportEvent(h, EVENTLOG_INFORMATION_TYPE, 0, 0, NULL, 1, 0, (const char **)ptbuf, NULL);
DeregisterEventSource(h);
va_end(marker);
}
@ -196,6 +197,40 @@ DWORD APIENTRY NPGetCaps(DWORD index)
}
}
static NET_API_STATUS
NetUserGetProfilePath( LPCWSTR Domain, LPCWSTR UserName, char * profilePath, DWORD profilePathLen )
{
NET_API_STATUS code;
LPWSTR ServerName = NULL;
LPUSER_INFO_3 p3 = NULL;
code = NetGetAnyDCName(NULL, Domain, (LPBYTE *)&ServerName);
if (code != NERR_Success)
return code;
if (ServerName == NULL)
return NERR_InvalidComputer;
code = NetUserGetInfo(ServerName, UserName, 3, (LPBYTE *)&p3);
if (code == NERR_Success)
{
code = NERR_UserNotFound;
if (p3) {
if (p3->usri3_profile) {
DWORD len = lstrlenW(p3->usri3_profile);
/* Convert From Unicode to ASCII */
len = len < profilePathLen ? len : profilePathLen - 1;
CharToOemBuffW(p3->usri3_profile, profilePath, len);
profilePath[len] = '\0';
code = NERR_Success;
}
NetApiBufferFree(p3);
}
}
NetApiBufferFree(ServerName);
return code;
}
BOOL IsServiceRunning (void)
{
SERVICE_STATUS Status;
@ -251,7 +286,8 @@ BOOL IsServiceRunning (void)
/* Get domain specific configuration info. We are returning void because if anything goes wrong
we just return defaults.
*/
void GetDomainLogonOptions( PLUID lpLogonId, char * username, char * domain, LogonOptions_t *opt ) {
void
GetDomainLogonOptions( PLUID lpLogonId, char * username, char * domain, LogonOptions_t *opt ) {
HKEY hkParm = NULL; /* Service parameter */
HKEY hkNp = NULL; /* network provider key */
HKEY hkDoms = NULL; /* domains key */
@ -885,9 +921,11 @@ VOID AFS_Logoff_Event( PWLX_NOTIFICATION_INFO pInfo )
if (QueryAdHomePathFromSid( profileDir, sizeof(profileDir), tokenUser->User.Sid, pInfo->Domain)) {
WCHAR Domain[64]=L"";
GetLocalShortDomain(Domain, sizeof(Domain));
if (QueryAdHomePathFromSid( profileDir, sizeof(profileDir), tokenUser->User.Sid, Domain))
if (QueryAdHomePathFromSid( profileDir, sizeof(profileDir), tokenUser->User.Sid, Domain)) {
if (NetUserGetProfilePath(pInfo->Domain, pInfo->UserName, profileDir, &len))
GetUserProfileDirectory(pInfo->hToken, profileDir, &len);
}
}
if (strlen(profileDir)) {
DebugEvent("Profile Directory: %s", profileDir);