Re: memberOf Property not listed
From: Matjaz Ladava (matjaz_at__nospam_ladava.com)
Date: 06/17/03
- Next message: Matjaz Ladava: "Re: Mixed security"
- Previous message: Matjaz Ladava: "Re: Urgent help needed"
- In reply to: Ren: "memberOf Property not listed"
- Next in thread: Ren: "Re: memberOf Property not listed"
- Reply: Ren: "Re: memberOf Property not listed"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
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
- Next message: Matjaz Ladava: "Re: Mixed security"
- Previous message: Matjaz Ladava: "Re: Urgent help needed"
- In reply to: Ren: "memberOf Property not listed"
- Next in thread: Ren: "Re: memberOf Property not listed"
- Reply: Ren: "Re: memberOf Property not listed"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Relevant Pages
|