I&#039;m trying to Impersonate a user thru code written in VB in an ASP page, so that I can connect to a Samba server on a Linux system for storing files.<BR><BR>The function LogonUSer(Win32 API call) fails when this is done. But, when the same code is run in VB, it works. <BR>Following are the things I have tried:<BR><BR>1) Removing the Anonymous Access from directory security tab of the Website in IIS. This works but we cannot afford it as <BR>we will be using Microsoft Challenge/Response services.<BR>2) Adding the DLL that has Impersonation function to COM+/MTS. It doesnot work. <BR>3) Performing Step2 and adding the Administrator security context to the Package. It doesnot work.<BR>4) We have tried the suggestions given in query Q248187, Q223334 in MSDN and microsoft support site. They don&#039;t seem to work either.<BR><BR>Could someone help!<BR>The basic idea behind the whole exercise is to move away from the Microsoft platform to Linux.<BR><BR><BR>Code we used:<BR><BR>ASP<BR>~~~<BR>&#060;%<BR>dim o, f<BR>set o = Server.CreateObject("Crypto.clsCrypto")<BR>set f = Server.CreateObject("Scripting.FileSystemObject") <BR><BR>o.Impersonate "fileuser","samba","system1234"<BR> f.CreateFolder "\sambapermfiles12"<BR> f.CreateTextFile "\sambapermfiles12
ew.txt"<BR>o.EndImpersonate<BR>%&#062;<BR><BR><BR> VB Component COde:<BR>~~~~~~~~~~~~~~~~~~<BR>Private Declare Function ImpersonateLoggedOnUser Lib "advapi32.dll" (ByVal hToken As Long) As Long<BR>Private Declare Function LogonUser Lib "advapi32.dll" Alias "LogonUserA" (ByVal lpszUsername As String, ByVal lpszDomain As String, ByVal lpszPassword As String, ByVal dwLogonType As Long, ByVal dwLogonProvider As Long, phToken As Long) As Long<BR>Private Declare Function RevertToSelf Lib "advapi32.dll" () As Long<BR><BR>Public Function Impersonate(ByVal sUserName As String, ByVal sDomain As String, ByVal sPassword As String) As Boolean<BR> Dim Result As Long<BR> Dim hToken As Long<BR> Dim lngLastErr As Long<BR> <BR> Call RevertToSelf<BR> Result = LogonUser(sUserName, sDomain, sPassword, LOGON32_LOGON_INTERACTIVE, LOGON32_PROVIDER_DEFAULT, hToken)<BR> Result = ImpersonateLoggedOnUser(hToken)<BR>End Function<BR><BR><BR>Thanks,<BR>Gautam