Can't pass custom credentials with remoting

Can't pass custom credentials with remoting

Old forum URL: forums.lhotka.net/forums/t/2356.aspx


miker55 posted on Thursday, February 15, 2007

I'm trying to use Windows authentication with something other than the default credentials.  Does anyone know what I'm doing wrong here?

TIA,

Mike

static RemotingProxy()

{

  // create and register a custom HTTP channel

  // that uses the binary formatter

  Hashtable properties = new Hashtable();

  properties["name"] = "HttpBinary";

  if (ApplicationContext.AuthenticationType == "Windows" || AlwaysImpersonate)

  {

    properties["credentials"] = new NetworkCredential("MIKE", "mypassword", "MYDOMAIN");

  }

  BinaryClientFormatterSinkProvider formatter = new BinaryClientFormatterSinkProvider();

  HttpChannel channel = new HttpChannel(properties, formatter, null);

  ChannelServices.RegisterChannel(channel, EncryptChannel);

}

 

miker55 replied on Friday, February 16, 2007

I got it to work.  Just in case anyone else needs it, here is what I had to do.  The issue was I had to pass the credentials *after* the portal got created:

private Server.IDataPortalServer Portal

{

  get

  {

    if (_portal == null)

    {

      _portal = (Server.IDataPortalServer)Activator.GetObject(

typeof(Server.Hosts.RemotingPortal),

ApplicationContext.DataPortalUrl.ToString());

      if (UserName != String.Empty)

      {

      // they specified a user name, so pass it to ISS for integrated authentication

      NetworkCredential nc = new NetworkCredential(UserName, Password, Domain);

      ChannelServices.GetChannelSinkProperties(_portal)["credentials"] = nc;

    }

  }

  return _portal;

}

}

Copyright (c) Marimer LLC