Re: Retrieving User's Groups from Active Directory using ASP.NET

From: L Magarian (LMagarian_at_discussions.microsoft.com)
Date: 09/28/04

  • Next message: Joe Kaplan \(MVP - ADSI\): "Re: Retrieving User's Groups from Active Directory using ASP.NET"
    Date: Tue, 28 Sep 2004 11:59:02 -0700
    
    

    The error is: "The specified domain either does not exist or could not be
    contacted ", and is thrown by the FindOne() method.
    The path I'm using looks like LDAP://company.com/CN=My Name,OU=User
    Accounts,OU=Accounts,DC=company,DC=com

    This is the method I'm using to get the user's groups:

    public string GetGroups()
    {
    DirectorySearcher search = new DirectorySearcher(_path);
    search.Filter = "(cn=" + _filterAttribute + ")";
    search.PropertiesToLoad.Add("memberOf");
    StringBuilder groupNames = new StringBuilder();

    SearchResult result = search.FindOne();
    int propertyCount = result.Properties["memberOf"].Count;
    int equalsIndex, commaIndex;

    for( int i = 0; i < propertyCount; i++)
                                    {
    String dn = (String)result.Properties["memberOf"][i];

    equalsIndex = dn.IndexOf("=", 1);
    commaIndex = dn.IndexOf(",", 1);
    if (-1 == equalsIndex)
    {
    return null;
    }
    groupNames.Append(dn.Substring((equalsIndex + 1), (commaIndex - equalsIndex)
    - 1));
    groupNames.Append("|");
    }
    return groupNames.ToString();
    }

    "Paul Clement" wrote:

    > On Tue, 28 Sep 2004 01:51:03 -0700, "L Magarian" <LMagarian@discussions.microsoft.com> wrote:
    >
    > ¤ I'm using forms based authentication and LDAP to authenticate a user against
    > ¤ Active Directory. This is working fine.
    > ¤
    > ¤ The point where I'm stuck is retireving the groups this user is assigned.
    > ¤
    > ¤ My web server and active directory servers are different machines. When I
    > ¤ test by deploying the web app on the active directory machine it does work.
    > ¤ However, I will not be able to employ this work around in the production
    > ¤ setting.
    > ¤
    > ¤ Can anyone advise me as to how retrieve these user groups?
    > ¤
    > ¤ Are there special settings for searching the Active Directory when running a
    > ¤ web app off a different server?
    >
    > Could you indicate what type of error you are receiving and identify the line of code where it
    > occurs?
    >
    >
    > Paul ~~~ pclement@ameritech.net
    > Microsoft MVP (Visual Basic)
    >


  • Next message: Joe Kaplan \(MVP - ADSI\): "Re: Retrieving User's Groups from Active Directory using ASP.NET"

    Relevant Pages

    • Re: AD Authentication from a Web Server in DMZ
      ... I don't believe that there is a way to do this without the webserver ... actually being a member of the Active Directory Domain. ... web app being dependent upon the domain and the domain being available. ... > Server, we'll do that. ...
      (microsoft.public.inetserver.iis)
    • Re: Retrieving Users Groups from Active Directory using ASP.NET
      ... I'm using forms based authentication and LDAP to authenticate a user against ... My web server and active directory servers are different machines. ... test by deploying the web app on the active directory machine it does work. ...
      (microsoft.public.dotnet.framework.aspnet.security)
    • Retrieving Users Groups from Active Directory using ASP.NET
      ... I'm using forms based authentication and LDAP to authenticate a user against ... My web server and active directory servers are different machines. ... test by deploying the web app on the active directory machine it does work. ...
      (microsoft.public.dotnet.framework.aspnet.security)
    • Re: 2003 Migration
      ... Best Practice Active Directory Design for Managing Windows Networks ... Windows Server 2003 Tools ... ensure that you have designed a DNS and Active ...
      (microsoft.public.windows.server.active_directory)
    • Re: i got 6 server in company which contains NT4 , windows 2000 , windowser 2003
      ... Best Practice Active Directory Design for Managing Windows Networks ... Windows Server 2003 Tools ... ensure that you have designed a DNS and Active ...
      (microsoft.public.windows.server.active_directory)