Bind to Moniker not working on Windows XP 32bit using LDAP - com

I have the following code:
<appSettings>
<add key="rootDN" value="LDAP://[The rest of the path]"/>
</appSettings>
string rootDN = System.Configuration.ConfigurationManager.AppSettings["rootDN"];
object ou = Marshal.BindToMoniker(rootDN);
This is producing an error:
Unhandled Exception:
System.Runtime.InteropServices.COMException
(0x80072020): A n operations error
occurred. (Exception from HRESULT:
0x80072020) at
System.Runtime.InteropServices.Marshal.MkParseDisplayName(IBindCtx
pbc, St ring szUserName, UInt32&
pchEaten, IMoniker& ppmk) at
System.Runtime.InteropServices.Marshal.BindToMoniker(String
monikerName) at
LDAP_CreateGroup.Program.Main(String[]
args)
Works fine on Windows Server 2008, not working on XP. Unfortunately need this to run on XP.

Must be logged on as domain user, run as user didn't work.

Related

MVC connection string: An error occured while processing your request

I'm new to Windows server and have no idea how to create connection string on my IIS for my website. I've already created my MVC website and it's working fine on my localhost.
But when I run it on IIS server in Plesk Panel, it gives an error:
An error occured while processing your request.
This happens whenever I try to make request to DB. When I want to sign up I face the error above.
Here's my connection string that I'm using:
<connectionStrings>
<add name="DefaultConnection"
connectionString="Data Source=.MSSQLSERVER2012;Initial Catalog=myDatabase;user=myDbUser;pwd=myDbPass; Integrated Security=True"
providerName="System.Data.SqlClient" />
In Data Source="Enter your server Name Here" If you still got an error share your error screen.

ConnectionStrings error 26 - SQL / Visual Studio

I have added a database file (NORTHWND.MDF) to my application using Visual Studio 2010 built-in functionality. Database is in the App_Data folder.
It is running fine in local-host. But when I publish it and upload it to server it gives this error:
A network-related or instance-specific error occurred while
establishing a connection to SQL Server. The server was not found or
was not accessible. Verify that the instance name is correct and that
SQL Server is configured to allow remote connections. (provider: SQL
Network Interfaces, error: 26 - Error Locating Server/Instance
Specified)
My connection string is that automatically generated by visual studio in my web.config:
<connectionStrings>
<add name="ConnectionString" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\NORTHWND.MDF;Integrated Security=True;Connect Timeout=30;User Instance=True"
providerName="System.Data.SqlClient" />
</connectionStrings>
My host support SQL Express, but it dont work..
I read that once everything is upped on the host do not have to use "AttachDbFilename" .. but I have not figured out how to fix it .. Could someone tell me the correct connection string?
Thanks in advance.
You Sholud Use this connection String if you have your db attached to SQL management Studio
Data Source=myServerAddress;Initial Catalog=myDataBase;Integrated Security=SSPI;
User ID=myDomain\myUsername;Password=myPassword;
Reference:
https://www.connectionstrings.com/sql-server/

System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown. download big file in mvc 4

I want to download a file in mvc That size is 200mb
The following error occurs :
System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown
my code is :
public FileResult Download(string name)
{
var videoFilePath = HostingEnvironment.MapPath("~/VideoFile/" + name + ".mp4");
//The header information
var file = new FileInfo(videoFilePath);
//Check the file exist, it will be written into the response
if (file.Exists)
{
return File(videoFilePath, System.Net.Mime.MediaTypeNames.Application.Octet,
file.Name);
}
return null;
}
The error does not occur when the file size is small
why ?
Recently I kept getting System.OutOfMemoryException exception while working on a web application with Visual Studio 2013.
The full exception message title was as follow:
System.OutOfMemoryException Exception of type 'System.OutOfMemoryException' was thrown.
To resolve this issue, I had to restart Visual Studio or go to the Windows Task Manager and terminate IIS Express process.
This error could happen due to a variety of reasons related to memory consumption of the application. Looking at my local machine memory, there was always enought memory available! Then what was the cause?
Turns out, Visual Studio uses IIS Exoress 32 bit version by default whereas 64 bit version is available right out there! So as a work around you go to the following path and make Visual studio to use 64 bit version of IISExpress.
Tools | Options | Projects and solutions | Web Projects => Use 64 bit version of IIS Express for websites and projects
Apparently behind the scene Visual Studio changes a flag in windows registry which the key could be found at this path.
HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\12.0\WebProjects --> Use64BitIISExpress
I believe your MVC 4 project needs to be updated to support 200 mb files and also, IIS needs to be updated to support 200 mb files.
To change it at the IIS level, I think adding this to your web.config file should work. (untested)
<system.webServer>
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="209715200"/>
</requestFiltering>
</security>
</system.webServer>
And to pull from another SO post, add the following to your web.config file
<location path="File">
<system.web>
<httpRuntime executionTimeout="60" maxRequestLength="4096" />
</system.web>
</location>
<location path="Picture">
<system.web>
<httpRuntime executionTimeout="60" maxRequestLength="1024" />
</system.web>
</location>
Where "File" and "Picture" are your controller names.
On that link, the accepted answer also addresses upload timeouts, which might be a problem as well for a 200 mb file.

provider: SQL Network Interfaces, error: 25 - Connection string is not valid

I developed this application on my local computer using VS2012 and SQL 2008R2. I am trying to move it onto production server. It is a virtual server with 2012 SQL Server. I checked all the properties for remote connection and everything is enabled. The application opens with the login screen and once I enter the username and password (this was created on my computer using WSAT. Now I get this error:
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 25 - Connection string is not valid)
This is what I have in web.config:
<connectionStrings>
<remove name="LocalSqlServer" />
<add connectionString="Server=\\events;Database=Digital Signage;Integrated Security=true" name="DSConnectionString" />
<add connectionString="data source=\\events;Integrated Security=SSPI;AttachDBFilename=c:\\DS\aspnetdb.mdf;User Instance=true" name="LocalSqlServer" providerName="System.Data.SqlClient" />
Not entirely sure, but some points which may help you troubleshoot:
You can use a resource like this to help you generate the appropriate connection string
I am not sure that Server=\\events sounds entirely right - you should perhaps replace this with the actual SQL instance name here when deploying remotely (either <machine name> or <machine name>\<instance name> for a named instance)
You probably don't need to explicitly state the port which SQL Server is listening on (if it's still the default 1433), but something to keep in mind
Do you have anywhere that you explicitly reference the connection string LocalSqlServer in your code? If so, have you changed that to reference the connection string DSConnectionString before building and deploying? (NB. It may be better to just keep the connection string entry but change the value of the connection string to what you need for the SQL 2012 instance, rather than creating a new connection string entry but I'm not sure about your specific use case)

WCF Service is showing error after implemented in IIS

In my project I am using Enterprise Library to connect to database. It is working fine when I run the application from Visual Studio directly.
But this is showing error connecting to database when hosted in IIS on same machine. I have added log trace and got the following error
Resolution of the dependency failed, type =
"Microsoft.Practices.EnterpriseLibrary.Data.Database", name =
"(none)". Exception occurred while: while resolving. Exception is:
InvalidOperationException - The type Database cannot be constructed.
You must configure the container to supply this value.
----------------------------------------------- At the time of the
exception, the container was:
Resolving Microsoft.Practices.EnterpriseLibrary.Data.Database,(none)
| Exception:Microsoft.Practices.ServiceLocation.ActivationException:
Activation error occured while trying to get instance of type
Database, key "" --->
Microsoft.Practices.Unity.ResolutionFailedException: Resolution of the
dependency failed, type =
"Microsoft.Practices.EnterpriseLibrary.Data.Database", name =
"(none)". Exception occurred while: while resolving. Exception is:
InvalidOperationException - The type Database cannot be constructed.
You must configure the container to supply this value.
----------------------------------------------- At the time of the
exception, the container was:
Resolving Microsoft.Practices.EnterpriseLibrary.Data.Database,(none)
---> System.InvalidOperationException: The type Database cannot be
constructed. You must configure the container to supply this value.
at
Microsoft.Practices.ObjectBuilder2.DynamicMethodConstructorStrategy.GuardTypeIsNonPrimitive(IBuilderContext
context, SelectedConstructor selectedConstructor) at
Microsoft.Practices.ObjectBuilder2.DynamicMethodConstructorStrategy.PreBuildUp(IBuilderContext
context) at
Microsoft.Practices.ObjectBuilder2.StrategyChain.ExecuteBuildUp(IBuilderContext
context) at
Microsoft.Practices.ObjectBuilder2.DynamicMethodBuildPlanCreatorPolicy.CreatePlan(IBuilderContext
context, NamedTypeBuildKey buildKey) at
Microsoft.Practices.ObjectBuilder2.BuildPlanStrategy.PreBuildUp(IBuilderContext
context) at
Microsoft.Practices.ObjectBuilder2.StrategyChain.ExecuteBuildUp(IBuilderContext
context) at Microsoft.Practices.Unity.UnityContainer.DoBuildUp(Type
t, Object existing, String name, IEnumerable1 resolverOverrides)
--- End of inner exception stack trace --- at
Microsoft.Practices.Unity.UnityContainer.DoBuildUp(Type t, Object
existing, String name, IEnumerable1 resolverOverrides) at
Microsoft.Practices.Unity.UnityContainer.DoBuildUp(Type t, String
name, IEnumerable`1 resolverOverrides) at
Microsoft.Practices.ServiceLocation.ServiceLocatorImplBase.GetInstance(Type
serviceType, String key) --- End of inner exception stack trace ---
at
Microsoft.Practices.ServiceLocation.ServiceLocatorImplBase.GetInstance(Type
serviceType, String key) at
Microsoft.Practices.ServiceLocation.ServiceLocatorImplBase.GetInstance[TService](String
key) at
Microsoft.Practices.EnterpriseLibrary.Data.DatabaseFactory.InnerCreateDatabase(String
name)
My web.config of service is contains as below
<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net"/>
<section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data"/>
</configSections>
<dataConfiguration defaultDatabase="OracleConnection">
<providerMappings>
<add databaseType="Microsoft.Practices.EnterpriseLibrary.Data.Oracle.OracleDatabase, Microsoft.Practices.EnterpriseLibrary.Data" name="Oracle.DataAccess.Client"/>
</providerMappings>
</dataConfiguration>
<connectionStrings>
<add name="OracleConnection" providerName="Oracle.DataAccess.Client" connectionString="User Id=***;Password=****;Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=*****)(PORT=1500)) (CONNECT_DATA=(SERVER = DEDICATED) (SERVICE_NAME =*****)));"/>
<add name="SybaseConnection" connectionString="providerName=Sybase.ASEOLEDBProvider;Server=****;Port=5050;Catalog=**;User Id=***;Password=****"/>
</connectionStrings>
I tried a lot but unable to find the cause of issue. :(
I checked the permission on the folder and Everyone has full control. WCF Service in IIS Anonymous access is enabled.
Could anyone please help?
The assembly you are using cannot find one of the assemblies it depends on, make sure all dependencies are either in the GAC or in the bin folder of your web app.
When i enabled 32 bit applications in IIS the error has been changed to
ORA-12638: Credential retrieval failed
The connection string is correct which is working with visual studio.
Is there any setting we need to do in Oralce part to acces connection from IIS?
This worked fine when updated sqlnet.ora file of oracle.