cancel
Showing results for 
Search instead for 
Did you mean: 

How to get ticket without password

dok
Champ in-the-making
Champ in-the-making
I have to get ticket without password. I impersonate user and try to call http://alfrecoserver/alfresco/wcservice/mg/util/login by adding credentials to request, but I get error:

The remote server returned an error: (500) Internal Server Error.
   at System.Net.HttpWebRequest.GetResponse()

I'm writing a C# DLL that can call Alfresco REST API services. Here is my code:


string URI = "http://alfrescoserver/alfresco/wcservice/mg/util/login";
string UPN = "username@domain";

HttpWebRequest request = WebRequest.Create(URI) as HttpWebRequest;
WindowsIdentity identity = new WindowsIdentity(UPN);
WindowsImpersonationContext context = null;

try {
   context = identity.Impersonate();
   request.Credentials = CredentialCache.DefaultNetworkCredentials;
}
catch (Exception e) {
   return e.Message + Environment.NewLine + e.StackTrace;
}
finally {
   if (context != null) {
      context.Undo();
   }
}

IWebProxy proxy = new WebProxy(proxyServer, proxyPort);
proxy.Credentials = new NetworkCredential(proxyUsername, proxyPassword);
request.Proxy = proxy;

try {
   using (HttpWebResponse response = request.GetResponse() as HttpWebResponse) {
      StreamReader sr = new StreamReader(response.GetResponseStream());

      return sr.ReadToEnd();
   }
}
catch (Exception e) {
   return (e.Message + Environment.NewLine + e.StackTrace);
}

Is there any other way I can get ticket without password?

Thanks!

Domagoj Krišto
11 REPLIES 11

dok
Champ in-the-making
Champ in-the-making
Yes, it was custom build. It was done by company we hired so I don't know details about it.

You could try http://localhost:8080/alfresco/service/api/login. You can read more about it here http://wiki.alfresco.com/wiki/2.1_REST_API#Get_Login_Ticket or here http://wiki.alfresco.com/wiki/Repository_RESTful_API_Reference#Login.

I hope that this will get you in right direction.

ganessan_p
Champ in-the-making
Champ in-the-making
Thanks for your reply. Those apis require username and password. I need to get a ticket from a browser through REST (AJAX xmlhttp) through the Active directory integration.

Looks like you have done similar stuff.