New Posts New Posts RSS Feed: Windows auth
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Windows auth

 Post Reply Post Reply
Author
mikedfox View Drop Down
Newbie
Newbie


Joined: 29-Apr-2010
Posts: 21
Post Options Post Options   Quote mikedfox Quote  Post ReplyReply Direct Link To This Post Topic: Windows auth
    Posted: 08-Dec-2010 at 2:30pm
Do you have any samples that show using Windows auth against a custom security table in silverlight.
 
my web.config contains
 
  <objectServer>
<serverSettings allowAnonymousLogin="false"  />
  </objectServer>
  
  </ideablade.configuration>
  <system.web>
  <compilation debug="true" targetFramework="4.0" />
  <authentication mode="Windows" />
  </system.web>
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>
</system.serviceModel>
 
before querying my entitymanager I call 
Manager.LoginAsync(null, LoginCallback, null);
 
and in my LoginManager : IEntityLoginManager
the credential comes across as null. In the drc, it says that if you use a null in the 
call to LoginAsynch, and the credentials will be your windows credentials, but this doesn't seem to be working.
I need a sample to follow, or maybe someone can see what I missed in the configuration.


Back to Top
kimj View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 09-May-2007
Posts: 1390
Post Options Post Options   Quote kimj Quote  Post ReplyReply Direct Link To This Post Posted: 08-Dec-2010 at 7:18pm
Sorry, we don't have a sample showing Windows ASP.NET authentication with a custom IEntityLoginManager.  The DRC is a bit misleading, since it's both assuming use ofthe AspNetAuthenticatingLoginManager and jumping ahead to the final result. 
 
The actual ILoginCredential passed into your Login method will be null, since that's what you passed from the client.  What the built-in login manager does, and what you need to do in your custom login manager, is grab the HttpContext.Current.User, which with Windows authentication enabled will be a WindowsPrincipal.   In the built-in manager we build a UserBase/UserIdentity from the WindowsPrincipal and return that from the login method.  Since the WindowsPrincipal can't be serialized to a Silverlight application you'll need to also build a UserBase/UserIdentity, or some other custom IPrincipal/IIdentity which can be serialized. 
Back to Top
mikedfox View Drop Down
Newbie
Newbie


Joined: 29-Apr-2010
Posts: 21
Post Options Post Options   Quote mikedfox Quote  Post ReplyReply Direct Link To This Post Posted: 09-Dec-2010 at 5:57am
I figured out the missing bit you mentioned. :)
 
Once I changed my login to
 
 
public IPrincipal Login(ILoginCredential credential, EntityManager entityManager)
{
var principal = new UserBase(HttpContext.Current.User.Identity);
return principal;
}
 
I get
 
" The Login could not be completed because the server did not respond.  Check that the server is available and contains a clientApplicationType='Silverlight' configuration setting."
 
I changed the serversettings in config to
<serverSettings allowAnonymousLogin="false"  loginManagerRequired="true" supportedClientApplicationType="Silverlight"/>
but that didn't help
Back to Top
mikedfox View Drop Down
Newbie
Newbie


Joined: 29-Apr-2010
Posts: 21
Post Options Post Options   Quote mikedfox Quote  Post ReplyReply Direct Link To This Post Posted: 09-Dec-2010 at 6:06am
doh, i figured out the last problem. I didn't folow your directions well enough :)
 
I was creating a UserBase from HttpContext.Current.User.Identity
 
Instead I needed to build a UserIdentity from  HttpContext.Current.User.Identity.Name, then build the new user base from that.
so the final form looks like
 
public IPrincipal Login(ILoginCredential credential, EntityManager entityManager)
{
var ident = new UserIdentity(HttpContext.Current.User.Identity.Name, "Custom"true);
var principal = new UserBase(ident);
return principal;
}
 
Thanks
Back to Top
kimj View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 09-May-2007
Posts: 1390
Post Options Post Options   Quote kimj Quote  Post ReplyReply Direct Link To This Post Posted: 09-Dec-2010 at 8:28am
Great!   Sorry I wasn't very clear - as you found neither WindowsPrincipal nor WindowsIdentity are serializable to Silverlight.
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down