Profile Picture

API Problems

Posted By dirigodev 4 Years Ago
You don't have permission to rate!
Author
Message
dirigodev
Posted 4 Years Ago
View Quick Profile
Junior Member

Junior Member (22 reputation)Junior Member (22 reputation)Junior Member (22 reputation)Junior Member (22 reputation)Junior Member (22 reputation)Junior Member (22 reputation)Junior Member (22 reputation)Junior Member (22 reputation)Junior Member (22 reputation)

Group: Forum Members
Last Active: 4 Years Ago
Posts: 4, Visits: 11
I find working with API difficult because it lacks documentation. I can hit the API from a web browser on my local machine in its current location and it works. I am now attempting to hit the service to create a user programmatically with a post from another webpage and it does not work. I believe my issue to be a permission problem. The Application pool has an identity as NetworkService. When folks are hitting the API from custom code how do they typically have permissions setup?



My error is:

HTTP Error 401.2 - Unauthorized

You are not authorized to view this page due to invalid authentication headers.



This is what I am testing: http://www.xxxxxxxxxxx.com/imailserverapi/CreateUser2.aspx?username=testUsername&fullname=someName&password=abc123#.



This is just a test URL. Obviously, we're not doing to use the API like this.



We are an ASP.NET shop so the .NET/C# is not a problem.
Mike R.
Posted 4 Years Ago
View Quick Profile
Time Traveler

Time Traveler (1.7K reputation)Time Traveler (1.7K reputation)Time Traveler (1.7K reputation)Time Traveler (1.7K reputation)Time Traveler (1.7K reputation)Time Traveler (1.7K reputation)Time Traveler (1.7K reputation)Time Traveler (1.7K reputation)Time Traveler (1.7K reputation)

Group: Administrators
Last Active: 2 Years Ago
Posts: 1.1K, Visits: 1.8K
What authentication do you have enabled for that site? Mine is working from off the sever, it has Anonymous Auth and windows auth enabled for the site, with the Network Service has read&execute, list, and read perms on the files and folders. The app pool is running under the network service

Mike R.
Ipswitch IMail
http://support.ipswitch.com
Visit and see our new knowledgebase!
dirigodev
Posted 4 Years Ago
View Quick Profile
Junior Member

Junior Member (22 reputation)Junior Member (22 reputation)Junior Member (22 reputation)Junior Member (22 reputation)Junior Member (22 reputation)Junior Member (22 reputation)Junior Member (22 reputation)Junior Member (22 reputation)Junior Member (22 reputation)

Group: Forum Members
Last Active: 4 Years Ago
Posts: 4, Visits: 11
I am now seeing errors in the api0421.txt file. They are as follows:



4/21/2014 - 9:09 AM : Error : IMailAPI_NET.IIMUser.Save : Access to the registry key 'HKEY_LOCAL_MACHINE\Software\Ipswitch\Messenger Server\Domains\mydomain.com\Users\tytytytyt' is denied.



4/21/2014 - 9:20 AM : Error : IMailAPI_NET.UserData.SaveXMLPreferences : Could not find a part of the path 'C:\Program Files (x86)\Ipswitch\IMail\Users\JPEEZY24\preferences.config'.
Mike R.
Posted 4 Years Ago
View Quick Profile
Time Traveler

Time Traveler (1.7K reputation)Time Traveler (1.7K reputation)Time Traveler (1.7K reputation)Time Traveler (1.7K reputation)Time Traveler (1.7K reputation)Time Traveler (1.7K reputation)Time Traveler (1.7K reputation)Time Traveler (1.7K reputation)Time Traveler (1.7K reputation)

Group: Administrators
Last Active: 2 Years Ago
Posts: 1.1K, Visits: 1.8K
What account is the app pool for your API page running under? Does that user have access to the registry? Try the network service.

Mike R.
Ipswitch IMail
http://support.ipswitch.com
Visit and see our new knowledgebase!
jharville
Posted 4 Years Ago
View Quick Profile
Supreme Being

Supreme Being (62 reputation)Supreme Being (62 reputation)Supreme Being (62 reputation)Supreme Being (62 reputation)Supreme Being (62 reputation)Supreme Being (62 reputation)Supreme Being (62 reputation)Supreme Being (62 reputation)Supreme Being (62 reputation)

Group: Administrators
Last Active: 2 Years Ago
Posts: 35, Visits: 167
You may also want to ensure that the directory where the users files/folder will be created also has been given permissions for the user the IIS app pool is running as(usually Network Service).
dirigodev
Posted 4 Years Ago
View Quick Profile
Junior Member

Junior Member (22 reputation)Junior Member (22 reputation)Junior Member (22 reputation)Junior Member (22 reputation)Junior Member (22 reputation)Junior Member (22 reputation)Junior Member (22 reputation)Junior Member (22 reputation)Junior Member (22 reputation)

Group: Forum Members
Last Active: 4 Years Ago
Posts: 4, Visits: 11
It is running as 'Network Service'
dirigodev
Posted 4 Years Ago
View Quick Profile
Junior Member

Junior Member (22 reputation)Junior Member (22 reputation)Junior Member (22 reputation)Junior Member (22 reputation)Junior Member (22 reputation)Junior Member (22 reputation)Junior Member (22 reputation)Junior Member (22 reputation)Junior Member (22 reputation)

Group: Forum Members
Last Active: 4 Years Ago
Posts: 4, Visits: 11
This is my code:



using System.Text;

using System.Web.Security;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Web.UI.WebControls.WebParts;

using System.Web.UI.HtmlControls;



using IMailAPI_NET;







public partial class CreateUser2 : System.Web.UI.Page

{

public bool Worked;



protected void Page_Load(object sender, EventArgs e)

{

// each comes through as a string

string userName = Request.Form["username"];

string fullname = Request.Form["fullname"];



string domain = "domain.com";

string secret = ConfigurationManager.AppSettings["iMailSecret"];



UserData newUser = new UserData(domain);



newUser.Domain = domain;

newUser.UserID = userName;

newUser.FullName = fullname;

newUser.Password = secret;

newUser.MaxSize = 0;

newUser.MaxMessages = 0;

newUser.Disabled = false;



// write the directory (user directories are being created with config files inside the folders)

newUser.UserDir = "C:\\Program Files (x86)\\Ipswitch\\IMail" + "\\Users\\" + userName;



byte[] baUtf8 = Encoding.Convert(Encoding.Unicode, Encoding.UTF8, Encoding.Unicode.GetBytes(newUser.FullName));



bool worked = newUser.SaveUser(baUtf8);

// for testing

Worked = worked;



}





}
Edited
4 Years Ago by dirigodev
Tech DW
Posted 4 Years Ago
View Quick Profile
Time Traveler

Time Traveler (356 reputation)Time Traveler (356 reputation)Time Traveler (356 reputation)Time Traveler (356 reputation)Time Traveler (356 reputation)Time Traveler (356 reputation)Time Traveler (356 reputation)Time Traveler (356 reputation)Time Traveler (356 reputation)

Group: Administrators
Last Active: 8 Months Ago
Posts: 198, Visits: 609
This seems more permissions related than API/code related. I would run down the list of folders/registry and just confirm all the permissions are correct.

http://kb.imailserver.com
Mike R.
Posted 4 Years Ago
View Quick Profile
Time Traveler

Time Traveler (1.7K reputation)Time Traveler (1.7K reputation)Time Traveler (1.7K reputation)Time Traveler (1.7K reputation)Time Traveler (1.7K reputation)Time Traveler (1.7K reputation)Time Traveler (1.7K reputation)Time Traveler (1.7K reputation)Time Traveler (1.7K reputation)

Group: Administrators
Last Active: 2 Years Ago
Posts: 1.1K, Visits: 1.8K
Are you running it on the server using local host or connecting to it remotely? Is the site set to use anonymous and windows auth or just anonymous? Because if it is using windows auth as well, and using IE, then the user logged in must have permission to the registry as well.

Mike R.
Ipswitch IMail
http://support.ipswitch.com
Visit and see our new knowledgebase!


Similar Topics


Reading This Topic