12-28-2010 11:06 AM
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);
}
12-29-2010 12:59 PM
01-04-2011 07:48 AM
01-04-2011 08:09 AM
01-04-2011 11:09 AM
string URI = "http://alfrescoserver/alfresco/wcservice/mg/util/login";
string UPN = "username@domain";
// Make a request to a Uniform Resource Identifier (URI)
WebRequest request = WebRequest.Create(URI);
// Initializes a new instance of the WindowsIdentity class for the user represented by the specified User Principal Name (UPN)
WindowsIdentity identity = new WindowsIdentity(UPN);
// Represents the Windows user prior to an impersonation operation
WindowsImpersonationContext context = null;
try {
// Start impersonating. Allows code to impersonate a different Windows user
context = identity.Impersonate();
// Now impersonating
// Access resources using the identity of the authenticated user
// Sets the network credentials used for authenticating the request with the Internet resource
request.Credentials = CredentialCache.DefaultNetworkCredentials;
}
catch (Exception e) {
return e.Message + Environment.NewLine + e.StackTrace;
}
finally {
if (context != null) {
// Revert impersonation. Reverts the user context to the Windows user represented by this object
context.Undo();
}
}
try {
// Returns a response to an Internet request
using (WebResponse response = request.GetResponse()) {
StreamReader sr = new StreamReader(response.GetResponseStream());
return sr.ReadToEnd();
}
}
catch (Exception e) {
return (e.Message + Environment.NewLine + e.StackTrace);
}
01-04-2011 12:50 PM
01-05-2011 11:21 AM
string URI = "http://alfrescoserver/alfresco/wcservice/mg/util/login";
string UPN = "username@domain";
// Make a request to a Uniform Resource Identifier (URI)
WebRequest request = WebRequest.Create(URI);
request.CookieContainer = new CookieContainer(1);
request.Credentials = new NetworkCredential("username", "p@ssw0rd");
try {
// Returns a response to an Internet request
using (WebResponse response = request.GetResponse()) {
StreamReader sr = new StreamReader(response.GetResponseStream());
return sr.ReadToEnd();
}
}
catch (Exception e) {
return (e.Message + Environment.NewLine + e.StackTrace);
}
01-20-2011 10:35 AM
01-20-2011 01:20 PM
I've solved the problem!
I believe that we had a double-hop problem (http://blogs.msdn.com/b/knowledgecast/archive/2007/01/31/the-double-hop-problem.aspx).
This is what had to be done to solve this problem:
1. User that runs my DLL must be Windows Server 2003 domain user
2. Service that uses my DLL must have registered Service Principal Name in Domain controller with user that runs it (user that runs my DLL)
3. User that runs my DLL must not have Account is sensitive and cannot be delegated option selected in Domain controller
4. User that runs my DLL must have Trust this user for delegation to any service (Kerberos only) or Trust this user for delegation to specified services only option selected in Domain controller (if the user is in Windows Server 2003 functional domain this option is available only when you register Service Principal Name with this user)
5. Computer that runs service that uses my DLL must have Trust computer for delegation to any service (Kerberos only) or Trust computer for delegation to specified services only option selected in Domain Controller
This all (and more) is explained in Microsoft document Troubleshooting Kerberos Delegation. It contains:
* checklist for Active Directory,
* checklist for Client application,
* checklist for Middle tier,
* checklist for Back-end
plus
* configuration examples for common scenarios.
You can read more about Windows Authentication in ASP.NET 2.0 (http://msdn.microsoft.com/en-us/library/ff647076.aspx).
03-06-2012 05:56 PM
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.