.NET Remoting problem

Nov 3 2005 11:01 AM

Hi,

I am new to using .net remoting and am attempting to write an application to process login's against Active Directory.  Currently I have the following code for my remote object:

using System;
using System.Text;
using System.Collections;
using System.DirectoryServices;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Http;

namespace
ADRemote
{

/// <summary>

/// Summary description for ADRemote.

/// </summary>

public class ADRemote1 : MarshalByRefObject

{

private string _path;

private string _filterAttribute;

public ADRemote1()

{

//

// TODO: Add constructor logic here

//

_path = @"LDAP://domain.com";

}

public bool IsAuthenticated(string domain, string username, string pwd)

{

string domainAndUsername = domain + @"\" + username;

DirectoryEntry entry = new DirectoryEntry(_path, domainAndUsername, pwd);

try

{

//Bind to the native AdsObject to force authentication.

object obj = entry.NativeObject;

DirectorySearcher search = new DirectorySearcher(entry);

search.Filter = "(SAMAccountName=" + username + ")";

search.PropertiesToLoad.Add("cn");

SearchResult result = search.FindOne();

if(null == result)

{

return false;

}

//Update the new path to the user in the directory.

_path = result.Path;

_filterAttribute = (string)result.Properties["cn"][0];

}

catch (Exception ex)

{

throw new Exception("Error authenticating user. " + ex.Message);

}

return true;

}

public string GetGroups()

{

DirectorySearcher search = new DirectorySearcher(_path);

search.Filter = "(cn=" + _filterAttribute + ")";

search.PropertiesToLoad.Add("memberOf");

StringBuilder groupNames = new StringBuilder();

try

{

SearchResult result = search.FindOne();

int propertyCount = result.Properties["memberOf"].Count;

string dn;

int equalsIndex, commaIndex;

for(int propertyCounter = 0; propertyCounter < propertyCount; propertyCounter++)

{

dn = (string)result.Properties["memberOf"][propertyCounter];

equalsIndex = dn.IndexOf("=", 1);

commaIndex = dn.IndexOf(",", 1);

if(-1 == equalsIndex)

{

return null;

}

groupNames.Append(dn.Substring((equalsIndex + 1), (commaIndex - equalsIndex) - 1));

groupNames.Append("|");

}

}

catch(Exception ex)

{

throw new Exception("Error obtaining group names. " + ex.Message);

}

return groupNames.ToString();

}

}

}

This compiles, but when i try to reference it from my client, in this case a Web form to login, I get this error: 
Exception Details: System.Runtime.Remoting.RemotingException: Requested Service not found

Can someone explain how to implement remoting using http channel?  Is there something special I need to do to IIS or to my client app?

Thanks in advance,

Nathan


Answers (1)