ServiceResponseException: There are no public folder servers available - c#

I have been doing C# application which can access Public Folders through Exchange Web Services Managed API.
But there is Microsoft.Exchange.WebServices.Data.ServiceResponseException which says There are no public folder servers available.
My public folders will be like this.
Folder 1 --> Subfolder1 | Subfolder2 | Subfolder3
Folder 2 --> Subfolder1 | Subfolder2
Folder 3
Folder 4 --> Subfolder1
The exception throws when the application access to Folder 2.
The application can access Folder 1 and display all 3 subfolders.
Exception throws here:
Folder parentFolder = Folder.Bind(folderID, foldView.PropertySet);
I have tried recursive traversal and other possible ways. But problem still remains.
Please help me! I will be very very grateful for your guidance

I got this error, because I did not set the credentials.
So please check if you have set the credentials.
exchangeService.Credential = new NetworkCredential("UserName","Pasword", "Domain");

Related

Why can't I create a file in LocalApplicationData? C# , VS 2022, Windows 11

I know that there are restrictions to file operations, but SpecialFolder.LocalApplicationData is supposed to be for application use.
string _myFilePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "MyFile.txt"); //Line1
Console.WriteLine(_myFilePath); //Line2
Console.WriteLine(File.Exists(_myFilePath)); //Line3
Console.WriteLine(File.Create(_myFilePath)); //Line4
This is the console output:
The program stops at the 4th line and VS 2022 shows this error:
How can I create or delete files/folders in SpecialFolder.LocalApplicationData ? Or which folder is recommended for this kind of file/folder operations?
Using Windows 11, VS 2022 17.2.0 Preview 5.0 and NET 6.0 without administrator privileges:
Your code worked fine for me.
Output:
C:\Users\Edgar\AppData\Local\MyFile.txt
False
System.IO.FileStream
But here is my suggestion:
Check the ACLs of your directory: Is your account permitted for creating new files?
(Right-click the directory -> Properties -> Security -> Select your own user and check your permissions.)
Usually you should not create files directly under your %localappdata% directory.
If you need a temp-file, I would recommend to use Path.GetTempFileName() for getting a unique file name.
If you want to store files for a longer time, then I would recommend to create a directory for your application in %localappdata% and save the files there.
Sample:
string myApplicationDirectory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "MyApplication");
string myApplicationFile = Path.Combine(myApplicationDirectory, "myFile.txt");
if (!Directory.Exists(myApplicationDirectory)) {
Console.WriteLine($"Creating directory: {myApplicationDirectory}");
Directory.CreateDirectory(myApplicationDirectory);
}
File.Create(myApplicationFile);
Console.WriteLine($"File created: {myApplicationFile}");
Output:
Creating directory: C:\Users\Edgar\AppData\Local\MyApplication
File created: C:\Users\Edgar\AppData\Local\MyApplication\myFile.txt

Cybersource Simple Order Api. The system cannot find the file specified Error Message

I have a .Net website (not a Web Application) project running in framework version 4.6.2
My implementation of the Cybersource simple order api works correctly on the development machine. However when i deploy my website to stage or product i receive the error The system cannot find the file specified when attempting the following code below.
NVPClient.RunTransaction(_cyberSourceConfig, request);
I have checked that the keys are valid. The _cyberSourceConfig contains the correct Currency, MerchantId, KeyFile, Key Directory and the locations are valid within the file system.
Check that the following DLL's are included within the projects bin directory
I have also checked that the following DLL's are in my projects bin directory.
CyberSource.Base.dll
CyberSource.Clients.dll
CyberSource.Clients.xml
_cyberSourceConfig consists of the the following
private CyberSource.Clients.Configuration _cyberSourceConfig = new CyberSource.Clients.Configuration();
_cyberSourceConfig.ConnectionLimit = -1;
_cyberSourceConfig.KeyFilename = "setting for key file"
_cyberSourceConfig.KeysDirectory = "path to keys directory"
_cyberSourceConfig.MerchantID = "My merchant id"
_cyberSourceConfig.SendToProduction = false;
_cyberSourceConfig.ServerURL = "https://ics2wstesta.ic3.com/commerce/1.x/transactionProcessor/";
Based on your provided information, I would suspect that you are specifying a file that is resolvable on your development machine, but is not resolving properly on your staging / production server.
_cyberSourceConfig.KeyFilename = #"keys.foo";
_cyberSourceConfig.KeysDirectory = #"C:\KeysDirectory\MyKeys\"; // <-- are you sure?
You need to make sure that either the relative or absolute paths are the same or are resolving to the file properly when using different enviornments.
Set your App Pool to Load User Profile: True
http://www.daves-blog.net/post/2014/06/16/X509Certificate-The-System-cannot-find-the-file-specified.aspx
That link is going to a 404 now, but the more general answer is fleshed out in this question.
CryptographicException was unhandled: System cannot find the specified file

Microsoft.Web.Administration get sub application

Say I have this type of config:
Site 1 (with an AppPool)
Virtual Directory
Virtual Directory 2
Site 2 (with an AppPool)
I'm tring to get the Site 2 informations but the only thing I can get is the path to the folder.

How to add local service priviledge on folder by C#

i was finding how to programmatically add local service priviledge on folder in C:\Program Files by C# and got a write up from this url http://stackoverflow.com/questions/5298905/add-everyone-privilege-to-folder-using-c-net/5398398#5398398
they show how to do this for everyone user.
DirectorySecurity sec = Directory.GetAccessControl(path);
// Using this instead of the "Everyone" string means we work on non-English systems.
SecurityIdentifier everyone = new SecurityIdentifier(WellKnownSidType.WorldSid, null);
sec.AddAccessRule(new FileSystemAccessRule(everyone, FileSystemRights.Modify | FileSystemRights.Synchronize, InheritanceFlags.ContainerInherit | InheritanceFlags.ObjectInherit, PropagationFlags.None, AccessControlType.Allow));
Directory.SetAccessControl(path, sec);
just tell me what i need to change in above code as a result local service privilege will be add on a specific folder.
i develop a windows service which will create a folder and xml file in it at run time. when i install my service from setup file then folder is not getting created but no error is also return.
so i debug the service and saw it could create folder and xml file in it during debugging time. the issue is occurred when i install the service from setup file. i am not being able to capture the issue like what problem is occuring. so guide me what should i do to capture the issue like "Why my service not being able to create folder and file " looking for guidance. thanks
new SecurityIdentifier(WellKnownSidType.LocalServiceSid, null);
or
new SecurityIdentifier("S-1-5-19");

Adding a SQL Filetable folder as a Virtual Directory

Using IIS 7.5 .NET Framework 4. I have a web page that needs to access a SQL 2012 Filetable folder. In IIS, I set up the file table folder as a virtual directory & in the connection, I'm using my active directory account login as the account to "Connect as...". I'm able to access the FileTable folder in windows explorer by going to it's location:
\\computername\sqlexp2012\filetabledb\filetabletb_dir
In IIS, if I right click on the virtual folder, and then click Explore, it opens up a Windows Explorer instance & displays the files there (lots of PDF files).
However, if I try to access the virtual folder directly (http://localhost/virtualfoldername) by right-clicking & going to Manage Virtual Directory, or access it through a web page (http://mywebsite/vname) I get the following error.
Error Summary
HTTP Error 500.19 - Internal Server Error
The requested page cannot be accessed because the related
configuration data for the page is invalid.
Detailed Error Information
Module IIS Web Core
Notification BeginRequest
Handler Not yet determined
Error Code 0x80070032
Config Error
Config File
Requested URL http://localhost:80/virtualfoldername
Physical Path \computername\sqlexp2012\FileTableDB\FileTableTb_Dir
Logon Method Not yet determined
Logon User Not yet determined
Config Source
-1:
0:
If I go in to the Virtual Directory & go to Manage Virtual Directory --> Advanced Settings, I see the physical path to the SQL Filetable folder & Physical Path credentials. My user account is set up as dbo under Security --> Users. The IIS log file is not helpful, nor is anything in the Event Viewer.
Anything I've been able to find has said that it is likely permissions related, but using my account - which I know works, as far as accessing the file share via Windows Explorer - doesn't. Any thoughts welcome.
Thanks!

Categories

Resources