/*
* Copyright (c) 2008, 2009, 2010, 2011 Kernel Drivers, LLC.
- * Copyright (c) 2009, 2010, 2011 Your File System, Inc.
+ * Copyright (c) 2009, 2010, 2011, 2015 Your File System, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
static BOOL bServerNameRead = FALSE;
-LARGE_INTEGER
-AFSRetrieveAuthId( void);
-
void
ReadProviderNameString( void)
{
pConnectCB->Type = lpNetResource->dwType;
- pConnectCB->AuthenticationId = AFSRetrieveAuthId();
-
-#ifdef AFS_DEBUG_TRACE
- AFSDbgPrint( L"NPAddConnection3 Retrieved authentication id %08lX-%08lX\n",
- pConnectCB->AuthenticationId.HighPart,
- pConnectCB->AuthenticationId.LowPart);
-#endif
-
hControlDevice = OpenRedirector();
if( hControlDevice == NULL)
#ifdef AFS_DEBUG_TRACE
AFSDbgPrint( L"NPAddConnection3 Failed to add connection to file system %d\n", GetLastError());
#endif
- try_return( dwStatus = WN_OUT_OF_MEMORY);
+ try_return( dwStatus = WN_NET_ERROR);
}
//
pConnectCB->Version = AFS_NETWORKPROVIDER_INTERFACE_VERSION_1;
- pConnectCB->AuthenticationId = AFSRetrieveAuthId();
-
-#ifdef AFS_DEBUG_TRACE
- AFSDbgPrint( L"NPCancelConnection Retrieved authentication id %08lX-%08lX\n",
- pConnectCB->AuthenticationId.HighPart,
- pConnectCB->AuthenticationId.LowPart);
-#endif
-
hControlDevice = OpenRedirector();
if( hControlDevice == NULL)
pConnectCB->Version = AFS_NETWORKPROVIDER_INTERFACE_VERSION_1;
- pConnectCB->AuthenticationId = AFSRetrieveAuthId();
-
-#ifdef AFS_DEBUG_TRACE
- AFSDbgPrint( L"NPGetConnection Retrieved authentication id %08lX-%08lX\n",
- pConnectCB->AuthenticationId.HighPart,
- pConnectCB->AuthenticationId.LowPart);
-#endif
-
hControlDevice = OpenRedirector();
if( hControlDevice == NULL)
pConnectCB->Version = AFS_NETWORKPROVIDER_INTERFACE_VERSION_1;
- pConnectCB->AuthenticationId = AFSRetrieveAuthId();
-
-#ifdef AFS_DEBUG_TRACE
- AFSDbgPrint( L"NPGetConnection3 Retrieved authentication id %08lX-%08lX\n",
- pConnectCB->AuthenticationId.HighPart,
- pConnectCB->AuthenticationId.LowPart);
-#endif
-
hControlDevice = OpenRedirector();
if( hControlDevice == NULL)
pConnectCB->Version = AFS_NETWORKPROVIDER_INTERFACE_VERSION_1;
- pConnectCB->AuthenticationId = AFSRetrieveAuthId();
-
hControlDevice = OpenRedirector();
if( hControlDevice == NULL)
DWORD dwStatus = WN_SUCCESS;
AFSEnumerationCB *pEnumCB = NULL;
+ HANDLE hControlDevice = NULL;
#ifdef AFS_DEBUG_TRACE
if ( lpNetResource == NULL)
}
#endif
+ hControlDevice = OpenRedirector();
+
+ if( hControlDevice == NULL)
+ {
+
+#ifdef AFS_DEBUG_TRACE
+ AFSDbgPrint( L"NPOpenEnum OpenRedirector failure, returning WN_NET_ERROR\n");
+#endif
+
+ return WN_NO_NETWORK;
+ }
+
+ CloseHandle( hControlDevice);
+
+
*lphEnum = HeapAlloc( GetProcessHeap( ), HEAP_ZERO_MEMORY, sizeof( AFSEnumerationCB));
if( *lphEnum == NULL)
pEnumCB->RemoteName);
}
- pConnectionCB->AuthenticationId = AFSRetrieveAuthId();
-
-#ifdef AFS_DEBUG_TRACE
- AFSDbgPrint( L"NPEnumResource Retrieved authentication id %08lX-%08lX\n",
- pConnectionCB->AuthenticationId.HighPart,
- pConnectionCB->AuthenticationId.LowPart);
-#endif
-
dwError = DeviceIoControl( hControlDevice,
IOCTL_AFS_LIST_CONNECTIONS,
pConnectionCB,
pConnectCB->Version = AFS_NETWORKPROVIDER_INTERFACE_VERSION_1;
- pConnectCB->AuthenticationId = AFSRetrieveAuthId();
-
-#ifdef AFS_DEBUG_TRACE
- AFSDbgPrint( L"NPGetResourceInformation Retrieved authentication id %08lX-%08lX\n",
- pConnectCB->AuthenticationId.HighPart,
- pConnectCB->AuthenticationId.LowPart);
-#endif
-
hControlDevice = OpenRedirector();
if( hControlDevice == NULL)
pConnectCB->Version = AFS_NETWORKPROVIDER_INTERFACE_VERSION_1;
- pConnectCB->AuthenticationId = AFSRetrieveAuthId();
-
-#ifdef AFS_DEBUG_TRACE
- AFSDbgPrint( L"NPGetUniversalName Retrieved authentication id %08lX-%08lX\n",
- pConnectCB->AuthenticationId.HighPart,
- pConnectCB->AuthenticationId.LowPart);
-#endif
-
hControlDevice = OpenRedirector();
if( hControlDevice == NULL)
return hControlDevice;
}
-LARGE_INTEGER
-AFSRetrieveAuthId()
-{
-
- LARGE_INTEGER liAuthId = {0,0};
- HANDLE hToken = NULL;
- TOKEN_STATISTICS stTokenInfo;
- DWORD dwCopyBytes = 0;
-
- if ( !OpenThreadToken( GetCurrentThread(),
- TOKEN_QUERY,
- FALSE, // Impersonation
- &hToken))
- {
- if( !OpenProcessToken( GetCurrentProcess(),
- TOKEN_QUERY,
- &hToken))
- {
-
-#ifdef AFS_DEBUG_TRACE
- AFSDbgPrint( L"AFSRetrieveAuthId Failed to retrieve Thread and Process tokens 0x%X\n",
- GetLastError());
-#endif
- }
- else
- {
-
-#ifdef AFS_DEBUG_TRACE
- AFSDbgPrint( L"AFSRetrieveAuthId Retrieved Process Token\n");
-#endif
- }
- }
- else
- {
-
-#ifdef AFS_DEBUG_TRACE
- AFSDbgPrint( L"AFSRetrieveAuthId Retrieved Thread Token\n");
-#endif
- }
-
- if ( hToken != NULL)
- {
-
- if( !GetTokenInformation( hToken,
- TokenStatistics,
- &stTokenInfo,
- sizeof( TOKEN_STATISTICS),
- &dwCopyBytes))
- {
-
-#ifdef AFS_DEBUG_TRACE
- AFSDbgPrint( L"AFSRetrieveAuthId Failed to retrieve token information 0x%X\n",
- GetLastError());
-#endif
- }
- else
- {
-
- liAuthId.HighPart = stTokenInfo.AuthenticationId.HighPart;
- liAuthId.LowPart = stTokenInfo.AuthenticationId.LowPart;
- }
-
- CloseHandle( hToken);
- }
-
- return liAuthId;
-}
-
static DWORD
Debug(void)
{