]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
afslogon-20040722
authorJeffrey Altman <jaltman@mit.edu>
Thu, 22 Jul 2004 23:15:37 +0000 (23:15 +0000)
committerJeffrey Altman <jaltman@secure-endpoints.com>
Thu, 22 Jul 2004 23:15:37 +0000 (23:15 +0000)
the procedure used to obtain the profile directory failed in Domains
which were not Forests.  If ADS_NAME_INITTYPE_GC fails, we must try
ADS_NAME_INITTYPE_DOMAIN which requires the Domain.  Added a Domain
parameter to QueryAdHomePathFromSid.  This was easy to obtain in
the NPLogonNotify since the logon domain is provided as a parameter.
Unfortunately, the domain provided to the winlogon event notification
routine is the user authentication domain, not the logon domain for
the local machine.  Needed to create a  GetLocalShortDomain function
which uses the IADsADSystemInfo COM interface to obtain the local
short domain.  With this in place, we can now properly detect the
profile directory in all cases.

Document MaxLogSize in registry.txt

doc/txt/winnotes/registry.txt
src/WINNT/afsd/NTMakefile
src/WINNT/afsd/afslogon.c
src/WINNT/afsd/afslogon.h
src/WINNT/afsd/logon_ad.cpp

index 062e5036137677c005f3be4489c5488fbc781267..201289708c2ca46481a5f56bf55e27df04efeaf9 100644 (file)
@@ -312,6 +312,16 @@ Default : 2
     2 = Extended (GSS SPNEGO) authentication required
   The default is Extended authentication
 
+Value   : MaxLogSize
+Type    : DWORD {0 .. MAXDWORD}
+Default : 100K
+
+  This entry determines the maximum size of the %WINDIR%\TEMP\afsd_init.log 
+  file.  If the file is larger than this value when afsd_service.exe starts
+  the file will be reset to 0 bytes.  If this value is 0, it means the file
+  should be allowed to grow indefinitely.
+
+
 Regkey:
 [HKLM\SYSTEM\CurrentControlSet\Services\TransarcAFSDaemon\Parameters\GlobalAutoMapper]
 
index 088162b8bfea263593fd381e6b3f4935c3b93629..44c012ec74ca6f59f29032abe6f01f51ba1b4120 100644 (file)
@@ -218,7 +218,6 @@ LOGON_DLLLIBS =\
        $(DESTDIR)\lib\libafsconf.lib \
     $(DESTDIR)\lib\afsrxkad.lib \
     $(DESTDIR)\lib\afsdes.lib \
-    $(DESTDIR)\lib\lanahelper.lib \
     $(AFSKFWLIB)
 
 LOGON_DLLSDKLIBS =\
index 5f73ceb0522111b0528f7d8c937cc92057fd11ad..32e358dd9dea8d44df00f28dd0dc865f07e50df8 100644 (file)
@@ -849,8 +849,15 @@ VOID AFS_Logoff_Event( PWLX_NOTIFICATION_INFO pInfo )
         }
     }
 
-    if (QueryAdHomePathFromSid( profileDir, sizeof(profileDir), tokenUser->User.Sid))
-        GetUserProfileDirectory(pInfo->hToken, profileDir, &len);
+    /* We can't use pInfo->Domain for the domain since in the cross realm case 
+     * this is source domain and not the destination domain.
+     */
+    if (QueryAdHomePathFromSid( profileDir, sizeof(profileDir), tokenUser->User.Sid, pInfo->Domain)) {
+        WCHAR Domain[64]=L"";
+        GetLocalShortDomain(Domain);
+        if (QueryAdHomePathFromSid( profileDir, sizeof(profileDir), tokenUser->User.Sid, Domain))
+            GetUserProfileDirectory(pInfo->hToken, profileDir, &len);
+    }
     
     if (strlen(profileDir)) {
         DebugEvent("Profile Directory: %s", profileDir);
index 24565e1e277aa7a14e0e5a0603868d13ce892e60..dc1d4f6152a7286f2a0f07b62f1f29834da2444c 100644 (file)
@@ -119,7 +119,8 @@ static BOOL WINAPI UnicodeStringToANSI(UNICODE_STRING uInputString, LPSTR lpszOu
 void GetDomainLogonOptions( PLUID lpLogonId, char * username, char * domain, LogonOptions_t *opt );
 DWORD GetFileCellName(char * path, char * cell, size_t cellLen);
 DWORD GetAdHomePath(char * homePath, size_t homePathLen, PLUID lpLogonId, LogonOptions_t * opt);
-DWORD QueryAdHomePathFromSid(char * homePath, size_t homePathLen, PSID psid);
+DWORD QueryAdHomePathFromSid(char * homePath, size_t homePathLen, PSID psid, PWSTR domain);
+BOOL GetLocalShortDomain(PWSTR Domain);
 
 #ifdef __cplusplus
 }
index 39a97412c655b8b504f5a787b9a03c664ae2b587..13a6690bee2847ab55419234c2622db6bcf02545 100644 (file)
@@ -194,15 +194,20 @@ ghp_0:
        return code;
 }
 
-DWORD QueryAdHomePathFromSid(char * homePath, size_t homePathLen, PSID psid) {
+DWORD QueryAdHomePathFromSid(char * homePath, size_t homePathLen, PSID psid, PWSTR domain) {
        DWORD code = 1; /* default is failure */
        NTSTATUS rv = 0;
        HRESULT hr = S_OK;
        LPWSTR p = NULL;
        WCHAR adsPath[MAX_PATH] = L"";
        BOOL coInitialized = FALSE;
+    CHAR ansidomain[256], *a;
 
        homePath[0] = '\0';
+    
+    /* I trust this is an ASCII domain name */
+    for ( p=domain, a=ansidomain; *a = (CHAR)*p; p++, a++);
+    DebugEvent("Domain: %s", ansidomain);
 
     if(ConvertSidToStringSidW(psid,&p)) {
         IADsNameTranslate *pNto;
@@ -221,11 +226,16 @@ DWORD QueryAdHomePathFromSid(char * homePath, size_t homePathLen, PSID psid) {
 
         if(FAILED(hr)) { DebugEvent("Can't create nametranslate object"); }
         else {
-            hr = pNto->Init(ADS_NAME_INITTYPE_GC,L""); //,clientUpn/*IL->UserName.Buffer*/,IL->LogonDomainName.Buffer,IL->Password.Buffer);
+            hr = pNto->Init(ADS_NAME_INITTYPE_GC,L"");
             if (FAILED(hr)) { 
-                DebugEvent("NameTranslate Init failed [%ld]", hr);
+                DebugEvent("NameTranslate Init GC failed [%ld]", hr);
+                hr = pNto->Init(ADS_NAME_INITTYPE_DOMAIN,domain);
+                if (FAILED(hr)) { 
+                    DebugEvent("NameTranslate Init Domain failed [%ld]", hr);
+                }
             }
-            else {
+
+            if (!FAILED(hr)) {
                 hr = pNto->Set(ADS_NAME_TYPE_SID_OR_SID_HISTORY_NAME, p);
                 if(FAILED(hr)) { DebugEvent("Can't set sid string"); }
                 else {
@@ -311,10 +321,17 @@ DWORD GetAdHomePath(char * homePath, size_t homePathLen, PLUID lpLogonId, LogonO
 
             rv = LsaGetLogonSessionData(lpLogonId, &plsd);
             if(rv == 0) {
-                if(!QueryAdHomePathFromSid(homePath,homePathLen,plsd->Sid)) {
+                PWSTR domain;
+
+                domain = (PWSTR)malloc(sizeof(WCHAR) * (plsd->LogonDomain.Length+1));
+                memcpy(domain, plsd->LogonDomain.Buffer, sizeof(WCHAR) * (plsd->LogonDomain.Length));
+                domain[plsd->LogonDomain.Length] = 0;
+
+                if(!QueryAdHomePathFromSid(homePath,homePathLen,plsd->Sid,domain)) {
                     DebugEvent("Returned home path [%s]",homePath);
                     opt->flags |= LOGON_FLAG_AD_REALM;
                 }
+                free(domain);
                 LsaFreeReturnBuffer(plsd);
             } else {
                 DebugEvent("LsaGetLogonSessionData failed [%lX]", rv);
@@ -329,3 +346,34 @@ DWORD GetAdHomePath(char * homePath, size_t homePathLen, PLUID lpLogonId, LogonO
                return code;
        }
 }
+
+BOOL GetLocalShortDomain(PWSTR Domain)
+{
+    HRESULT hr;
+    IADsADSystemInfo *pADsys;
+    BOOL coInitialized = FALSE;
+    BOOL retval = FALSE;
+
+    hr = CoInitialize(NULL);
+    if(SUCCEEDED(hr))
+        coInitialized = TRUE;
+
+    hr = CoCreateInstance(CLSID_ADSystemInfo,
+                           NULL,
+                           CLSCTX_INPROC_SERVER,
+                           IID_IADsADSystemInfo,
+                           (void**)&pADsys);
+    if ( !FAILED(hr) ) {
+        BSTR bstr;
+
+        hr = pADsys->get_DomainShortName(&bstr);
+        wcscpy( Domain, bstr );
+        pADsys->Release();
+        retval = TRUE;
+    }
+
+       if(coInitialized)
+               CoUninitialize();
+
+    return retval;
+}