.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

error writing to directory in impersonated MVC APP

Posted By:      Posted Date: October 12, 2010    Points: 0   Category :ASP.Net

Hi All 


I have an MVC app that produces a PDF  on a button click impersonation is turned on and the account that is impersonating is a domain account with full rights to the   C:\Users\TEMP.IIS APPPOOL\ directory and everything under it. Any idea why I can write to that directory?




Server Error in '/GPOS' Application.

Access to the path 'C:\Users\TEMP.IIS APPPOOL\AppData\Local\Temp\temp_496f2b08-7f40-4d5a-96d3-80e228fb2b24.rpt' is denied.

View Complete Post

More Related Resource Links

Error on Display user's fullname using Active Directory in asp.net using vb.net



wi As System.Security.Principal.WindowsIdentity =  _System.Security.Principal.WindowsIdentity.GetCurrent()



Dim a As String() = HttpContext.Current.User.

Writing Bitmap to Response.OutputStream - Generic Error Occured in GDI+



This is what I'm trying to do when I get the error on the server (it works on my local machine):

System.Drawing.Image image = System.Drawing.Image.FromFile(filepath);
System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(image); 

Response.ContentType = "image/bmp";
bmp.Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Bmp);

I don't think it can be a permissions problem because this works on the server:

System.Drawing.Image image = System.Drawing.Image.FromFile(filepath);
System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(image);

Response.ContentType = "image/jpeg";
bmp.Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg);

So how do I get this to work for a bitmap?


Writing a Telephone Book / Corporate Phone Directory...

Hey everyone, I'm attempting to write one aspx page (vb.net back end) that pulls the following using an LDAP query from my active directory and dumps it into either a datagrid or a gridview control.  The fields I want to show from Active directory are;  1. Last Name 2. First Name 3. Office 4. Email 5. Telephone number (primary) 6. Mobile  7. Title 8. Department 9. Company ---- I only want to show the "active" users and then again, dump the results in a dataset and populate a datagrid / gridview control.  Does anyone have any sample code of this or can walk me through on how to do this - thanks in advance... Best regards, Ryan  

wcf in a sub directory of an web apps... (error)

Hi, We have an application 2 applications(asp.net), one is the web apps and the other one is wcf. we currently hosted those two into two different servers. It works fine... unfortunately our application having a security issue... and the solution is to have a sub directory in web apps, which is the wcf... BUT we got this error... The content type text/html; charset=utf-8 of the response message does not match the content type of the binding (text/xml; charset=utf-8). If using a custom encoder, be sure that the IsContentTypeSupported method is implemented properly. The first 1024 bytes of the response were: ' 3 stars and a sun

Directory lookup for the file failed with the operating system error 5

Hi I have a Windows desktop application that uses a SQLServer Express database.  The database files are downloaded from my website, followed by the application download (written in VBE).  The first procedure is to attach the database to the SQLServer instance from within the application. I have two test machines one runs Windows XP x84, the other Windows 7 x64.  I never have issues on attaching the database files in my test envirnoment but twice now other people downloading have got the following error System.Data.Sqlclient.sqlexception (ox 80131904) Directory lookup for the file C:\Documtents and Settings\Administrator\Desktop\Tem1.mdf failed with the operating system error 5 (failed to retrieve text for this error. Reason 1815) changed database context to 'master'. I'm not sure what the problem is and therefore how to correct the issue.  I attach the database in code using the create statement e.g. cmd7.CommandText = "USE Master CREATE DATABASE Tem1 ON PRIMARY (FILENAME = '" & DBFullPath & "') LOG ON (FILENAME = '" & DbLogPath & "') FOR ATTACH" Any help or suggestions would be very much appreciated. Chris    

Creating Database gives error : "Directory lookup for the file "xxxxx.mdf" failed with the operating

Hello FriendsI am creating Database using SQLDMOcode is as follows... Code Snippet SQLServer2Class server = new SQLServer2Class();server.EnableBcp = true;server.Connect(WebConfigurationManager.AppSettings["ServerName"] ,WebConfigurationManager.AppSettings["UserName"],WebConfigurationManager.AppSettings["Password"]);DBFileClass dbFile = new DBFileClass();           dbFile.Name = dbName;          dbFile.PhysicalName = "C:\\" + dbName + ".mdf";          dbFile.Size = 300;          dbFile.FileGrowthType = SQLDMO_GROWTH_TYPE.SQLDMOGrowth_MB;          dbFile.FileGrowth = 25;          dbFile.PrimaryFile = true;          LogFile2Class dbLogFile = new LogFile2Class();          dbLogFile.Name = dbName + "_log";          dbLogFile.PhysicalName = "C:\\" + dbName + "_log.ldf";          dbLogFile.FileGrowthType = SQLDMO_GROWTH_TYPE.SQLDMOGrowth_Percent;          dbLogFile.FileGrowth = 10;          Database2Class newDb = new Database2Class();          newDb.Name = dbName;          newDb.FileGroups.Item("PRIMARY").DBFiles.Add((DBFile)dbFile);          newDb.TransactionLog.LogFiles.Add((_LogFile)dbLogFile);          server.Databases.Add((_Database)newDb); This Code Generates Following Error !!]Microsoft][ODBC SQL Server Driver][SQL Server]Directory lookup for the file "D:\Projects\my_system\mySys

i cannot access iis virtual directory using http protocol..getting status code error 403

i am trying to connect to remote exchange using powershell..while using powershell session i get status error 403...i changed the settings in iis manager...i have set all the settings in the iis manager as said in the msdn support blogs...yet i get the same error when i access it in the client url and also in powershell of the client computer...if i cannot connect using powershell,can i connect using .net???somebody help me...i am beginner and i am stuck...

Error handling: writing database errors to a table that will not get removed by a rollback


I have an error handler sproc that issues a RAISERROR statement.  I would like for this sproc to write error messages to a table.  No problem so far.  What if there is a nested transaction with several ROLLBACKs?  If the code is only 1 level deep the error handler sproc can write to the error message table after the ROLLBACK.  If the code is 2 or more levels deep and an error occurs then what is written to the error message table might get rolled back if an error occurs after returning to the 1st level.  What I thought I would like to do is to have the error handler spawn a sub-process that would record the error message, where the sub-process would not be affected by any subsequent ROLLBACKs in the calling sproc.  Thoughts?

Writing File in Oracle to Secured Directory on NAS Server


I have a stored procedure that creates a comma delimited file. I can easily write to a directory on the database server, but I would like to write the file to a mapped network directory on a NAS server. The issue, at least conceptually (sorry for being a novice here), is that I have no way of accessing or embedding the necessary username/password to write to the specified directory.

Based on initial research, it looks like the oracle account is the one writing the file. Would that mean that the oracle account would have to have the appropriate privileges to the NAS directory? Who would that oracle user be? The niku account user being used to execute the proc?

Kind of lost here. Would like to send directly to the NAS to avoid an SFTP to another environment.

build error allowDefinition='MachineToApplication beyond app level, can be caused by virt directory


Hi I used the converter wizard in VS 2008 to  convert a web application from 2003.  I get one build  error as described above.  I went into IIS and created a virt directory but still get the error.  Any ideas?

Thanks Paul. 

SQLServer Error: 15404 with Active Directory



I'm having trouble running jobs with my active directory (ADS) account. I've setup my SQL services to run under an ADS account, but jobs cannot seem to query ADS for user information. We're running Windows Server 2003 and SQL Server 2005 SP2.

 Here is the error message:


The job failed.  Unable to determine if the owner (ADS\me) of job eFASRtest has server access (reason: Could not obtain information about Windows NT group/user 'ADS\me', error code 0x5. [SQLSTATE 42000] (Error 15404)).



also this message in log:


[298] SQLServer Error: 15404, Could not obtain information about Windows NT group/user 'ADS\me, error code 0x5. [SQLSTATE 42000] (ConnIsLoginSysAdmin)



I have done a *lot* of searching and cannot find the solution. I believe the 0x5 code is access denied. 

The same job runs if I change the owner to a SQL login that's not an ADS account.

I'm not certain how to confirm that the SQL Agent account is the account actually querying ADS, also.

Any help would be greatly appreciated!





Parameter error writing to excell 2007 file using SQL 2008 Server Agent JOB, works in BIDS.


I am getting the following error message when I try to run a script that writes to an excel file calling my Package with a SQL 2008 JOB.

Executed as user: xxxx\xxxxxxx. Microsoft (R) SQL Server Execute Package Utility  Version 10.0.1600.22 for 32-bit  Copyright (C) Microsoft Corp 1984-2005. All rights reserved.    Option "12.0;HDR=YES;" is not valid.  The command line parameters are invalid.  The step failed.

This same package runs correctly if I execute it in dev mode in BIDS.  I had to set 64bitmode to false in Dev mode to get it to work.  I set executable options in the job step to 'run in 32 bit mode'  The error message indicates to me it is trying to run in 32 bit mode which should be correct but it doesn't like the extended parameters. .   

Here is my connection string from the data sources tab on the job

Provider=Microsoft.ACE.OLEDB.12.0;Data Source=c:\xxxx.xlsx;Extended Properties="EXCEL 12.0;HDR=YES";

This was filled in ny the connection object for me.  I have read the article closely at http://toddmcdermid.blogspot.com/2009/10/quick-reference-ssis-in-32-and-64-bits.html and still can't figure out what I need to change. 

Active Directory bulk data update error System.DirectoryServices.DirectoryEntry.Bind(Boolean throwIf



we are trying to update bulk data into Active Directory from some database table. If we run for say 40000 users, it fails in between While updating its failing with an exception that. The server is not operational.

at System.DirectoryServices.DirectoryEntry.Bind(Boolean throwIfFail)
   at System.DirectoryServices.DirectoryEntry.Bind()
   at System.DirectoryServices.DirectoryEntry.get_AdsObject()
   at System.DirectoryServices.DirectorySearcher.FindAll(Boolean findMoreThanOne)
   at System.DirectoryServices.DirectorySearcher.FindOne()

Below is the piece of code updating the records ...


While drDataReader.Read()
                strMailID = drDataReader.Item(("EMAILID")).ToString()
                strAttributeName = drDataReader.Item("ATTRIBUTENAME").ToString().Trim()
                strAttributeValue = drDataReader.Item("ATTRIBUTEVALUE").ToString().Trim()

Error while accessing active directory


The asp.net files are on 2008 server running IIS.

From a client workstation (i.e. part of domain) I am running the website.

Below code is part of the intranet website:

String ldapPathString = LDAP://abc.au.xyz.com:123/OU=User Accounts,DC=au,DC=xyz,DC=com;

if(DirectoryEntry.Exists(ldapPathString)) \\at this line, I am getting the error

DirectoryEntry adsRoot = new DirectoryEntry(ldapPathString); 

adsRoot.AuthenticationType =

Active Directory Error


I get an error when I run the following code:


DirectoryEntry directory = new DirectoryEntry();
                directory.Path = "LDAP://" + ACTIVE_DIRECTORY_PATH;
                directory.Username = username;
                directory.Password = oldPassword;
                directory.AuthenticationType = AuthenticationTypes.Secure;
                directory.Invoke("ChangePassword", new object[] { newPassword });


It throws a nasty exception on direct.Invoke() and the error message is:

Unknown name. (Exception from HRESULT: 0x80020006 (DISP_E_UNKNOWNNAME))

I'd appreciate any help with this.

Throws an error message while adding users to the Active Directory


Hello guys,

I am trying to add a user to active directory but for some reason its failing


Here is the error message

Message: HandlingInstanceID: dde791c2-7df4-4214-85c4-72b045510def

An exception of type 'System.Runtime.InteropServices.COMException' occurred and was caught.


05/04/2011 15:18:30

Type : System.Runtime.InteropServices.COMException, mscorlib, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089

Message : The server is not operational.

Source : System.DirectoryServices

Help link :

ErrorCode : -2147016646

Data : System.Collections.ListDictionaryInternal

TargetSite : Void Bind(Boolean)

Stack Trace : at System.DirectoryServices.DirectoryEntry.Bind(Boolean throwIfFail)

at System.DirectoryServices.DirectoryEntry.Bind()

at System.DirectoryServices.DirectoryEntry.get_IsContainer()

at System.DirectoryServices.DirectoryEntries.CheckIsContainer()

at System.DirectoryServices.DirectoryEntries.Add(String name, String schemaClassName)



Building a Searchable Phone Directory with Windows SharePoint Services

I want to continue to build out the intranet site we've started in our previous articles. A standard item in every intranet is a staff/employee list. Most companies implementing Windows SharePoint Services (WSS) are large enough to have a database that contains all employees. We will use the aggregation features of SharePoint to include data from this database into our intranet.
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend