Re: memberOf Property not listed

From: Matjaz Ladava (matjaz_at__nospam_ladava.com)
Date: 06/17/03


Date: Tue, 17 Jun 2003 23:21:38 +0200


you are missing
search.PropertiesToLoad.Add("memberOf");

in your code.

-- 
Regards
Matjaz Ladava, MCSE (NT4 & 2000)
matjaz@ladava.com
http://ladava.com
"Ren" <malujoker@hotmail.com> wrote in message
news:55a25dcd.0306170413.fa9d908@posting.google.com...
> I am trying to list the groups that a windows user is a member of
> through an ASP.net application with a C# backend.  Though when I try
> to access the memberOf property, I keep getting "Object reference not
> set to an instance of an object."  Also when I loop through the
> propertyNames, memberOf is not listed.  Any help would be appreciated.
>
> Here is my code:
>
> //in web.config
> <authentication mode="Windows" />
> <identity impersonate="true" />
>
> //in webform1.aspx.cs
> //this gets the user identity and userName
> WindowsPrincipal currentUser = HttpContext.Current.User as
> WindowsPrincipal;
> int startI = currentUser.Identity.Name.ToString().IndexOf('\\') + 1;
> int endI = currentUser.Identity.Name.ToString().Length - startI ;
> string userName = (currentUser.Identity.Name.ToString()).Substring(startI,
> endI);
>
> DirectorySearcher search = new DirectorySearcher("LDAP://MyDomain/");
> search.Filter = "(cn=" + userName + ")";
>
> StringBuilder groupNames = new StringBuilder();
> SearchResult result = search.FindOne();
> DirectoryEntry userEntry = result.GetDirectoryEntry();
>
>
> //this lists all properties of the user, but fails to list memberOf
> foreach(String s in userEntry.Properties.PropertyNames)
>    Response.Write(s +"\t   <br>");
>
> //this is where I get the error, I have tried it several ways
> ResultPropertyValueCollection pvc = result.Properties["memberOf"];
> foreach(object val in pvc)
> {
>   Response.Write(val.ToString());
> }
>
>
>
> Thanks for any help in advance,
> Ren


Relevant Pages

  • wireless usb adapter for fedora core 13
    ... I am using Fedora core 13 operating system ... using checksum file in windows ... As much as I dislike absolute step-by-step instructions, ... read messages from the public lists. ...
    (Fedora)
  • Re: Spam Email
    ... > Is there any effective way of blocking spam email short of changing ... Whatever you do - do not try to get yourself OFF the lists in most cases. ... fill out in person that are not connected to the Internet (like insurance, ... I'll mainly work around Windows XP, as that is what the bulk of this ...
    (microsoft.public.windowsxp.basics)
  • Re: How to get rid of persistent virus programs.
    ... > Long query about dealing with Pesky trojans and spyware ... > At least something like before and after lists, ... I'll mainly work around Windows XP, as that is what the bulk of this ... Why you should use a computer firewall.. ...
    (microsoft.public.windowsxp.help_and_support)
  • Re: remote performance monitor problem
    ... allowed programs in your Windows Firewall setup. ... you have an installation problem - as the Windows Embedded ... unable to add objects to the chart since the Object lists are empty. ...
    (microsoft.public.windowsce.platbuilder)
  • Re: Anthonys drive issues.Re: ssh password delay
    ... the equivalent of Windows 2003 in terms of release ... drivers for the Mac, latest Windows, and Linux support. ... > FreeBSD. ... I got help from the lists, ...
    (freebsd-questions)