Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
|
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 23rd, 2004, 01:43 PM
ro ro is offline
Registered User
 
Join Date: Jun 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Active Directory (ADSI) C# Group Info LDAP Problem

I have written a Web Based Login Module in C# that authenticates against my local PDC. As far as the authentication goes, it works great. The problem comes when I try to get all the groups the user logging in belongs to. And what’s even WEIRDER is that it works fine when I run it from the development box (which is where the program resides and runs) but when I run (access it) it from another computer it will NOT get the group membership! Here’s the code I use (Keep in mind the strUser has already been authenticated against the AD):
Code:
string getGroups (string strUser){
        DirectoryEntry obEntry = new DirectoryEntry(
          "LDAP://DC=courthousedata,DC=com");

        DirectorySearcher srch = new DirectorySearcher(obEntry, 
          "(sAMAccountName=" + strUser + ")");

        SearchResult res = srch.FindOne();

        if (null != res){
          DirectoryEntry obUser = new DirectoryEntry(res.Path);
           object obGroups = obUser.Invoke("Groups");
          foreach (object ob in (IEnumerable)obGroups){
            DirectoryEntry obGpEntry = new DirectoryEntry(ob);
            groupNames.Append(obGpEntry.Name);
            groupNames.Append("|");
          }
        }

      return groupNames.ToString();
}
In IIS I have setup a user that has the ability to read the AD. (Again this works from the local machine, even if in the local machine I change from http://localhost to http://nameofbox it still works)

Any Help is appreciated!





Similar Threads
Thread Thread Starter Forum Replies Last Post
Add user to group - Active Directory anurag_ur ASP.NET 1.0 and 1.1 Professional 0 January 16th, 2006 09:25 AM
Add User to group - Active Directory anurag_ur .NET Framework 1.x 0 January 16th, 2006 09:15 AM
Add User to group - Active Directory anurag_ur C# 0 January 16th, 2006 09:13 AM
Add User to group - Active Directory anurag_ur ASP.NET 1.0 and 1.1 Basics 0 January 16th, 2006 09:13 AM
web application, get group name - active directory sara_1981 VB.NET 0 April 24th, 2004 01:36 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.