Re: listing Object properties from SearchResult

dl
Date: 05/14/05

  • Next message: Joe Kaplan \(MVP - ADSI\): "Re: listing Object properties from SearchResult"
    Date: Sat, 14 May 2005 08:48:08 +0800
    
    

    Hi Joe
    I just tried passing in the credentials with DirectoryEntry(strpath, uName,
    pwd, AuthenticationTypes.Secure) but it is still giving me the last name
    only!

    I guess I might have to revisit my whole dev setup for forms authentication.
    Is there a place / book I can look into about forms authentication with AD
    in ASP.NET? I thing I need to workout a checklist in each area.

    TIA

    "Joe Kaplan (MVP - ADSI)" <joseph.e.kaplan@removethis.accenture.com> wrote
    in message news:e4ejkT9VFHA.3216@TK2MSFTNGP10.phx.gbl...
    > The directoryentry used for the searchroot object determines the security
    > context that the search is performed with. It is possible that you are
    > authenticating anonymously, and thus can't see many properties. You can
    > verify this by passing in credentials to the DirectoryEntry before
    executing
    > the search and seeing if you get different results. If so, that was the
    > problem.
    >
    > If that is the problem, there are other ways to solve it than using a
    > hard-coded service account, but it is the easiest way to verify the issue.
    >
    > Joe K.
    >
    > <dl> wrote in message news:%23kJpCn8VFHA.2768@tk2msftngp13.phx.gbl...
    > >I did tried to throw in the PropertiesToLoad lines; one for each property
    > > that I was going to get. But that didn't make any difference.
    > > Interesting
    > > enough the account I am using (to login via login.aspx) to list this
    > > directory is the same as the one I used to create the entries and the
    OU.
    > > Do I need to pass on the credential (somewhere) to this page ? or do I
    > > need
    > > to bind with the credential?
    > > TIA
    > >
    > > Here is my code before the foreach statements ..
    > > String strPath = "LDAP://ou=" + txtOUName.Text +
    > > ",dc=domain,dc=com";
    > > //Bind to the OU
    > > DirectoryEntry myEnt = new DirectoryEntry(strPath);
    > >
    > > //do a DirectorySearch
    > > DirectorySearcher mySearcher = new DirectorySearcher(myEnt);
    > > mySearcher.PropertiesToLoad.Add("sn");
    > > mySearcher.PropertiesToLoad.Add("givenName");
    > > mySearcher.PropertiesToLoad.Add("telephoneNumber");
    > >
    > > mySearcher.Filter = "(objectClass=user)";
    > >
    > > SearchResultCollection resEntAll = mySearcher.FindAll();
    > >
    > >
    > > "Joe Kaplan (MVP - ADSI)" <joseph.e.kaplan@removethis.accenture.com>
    wrote
    > > in message news:uynwLa8VFHA.2692@TK2MSFTNGP15.phx.gbl...
    > >> What did you put in to PropertiesToLoad? Also, it is possible that the
    > >> security context you bound with only has rights to see a subset of the
    > >> properties you requested.
    > >>
    > >> Those are my two best guesses given what you've told us.
    > >>
    > >> Joe K.
    > >>
    > >> <dl> wrote in message news:OCHzJf4VFHA.1148@tk2msftngp13.phx.gbl...
    > >> > Hi
    > >> > I have the following lines of code that are suppose to list some
    > > selected
    > >> > properties of all the object entries in a SearchResult but the code
    is
    > >> > only
    > >> > listing one property ie. the 'sn' and the corresponding value for all
    > > the
    > >> > entries, do you have a clue why?
    > >> > TIA
    > >> > ----------------------
    > >> > foreach (SearchResult resEnt in resEntAll)
    > >> > {
    > >> > i++;
    > >> > dr = dt.NewRow();
    > >> > foreach (string propKy in
    > > resEnt.Properties.PropertyNames)
    > >> > {
    > >> > switch (propKy)
    > >> > {
    > >> > case "sn":
    > >> > y = 0;
    > >> > break;
    > >> > case "givenName":
    > >> > y = 1;
    > >> > break;
    > >> > case "telephoneNumber":
    > >> > y = 2;
    > >> > break;
    > >> > default:
    > >> > y = 3;
    > >> > break;
    > >> > }
    > >> > if (y < 3)
    > >> > {
    > >> > ResultPropertyValueCollection valco =
    > >> > resEnt.Properties[propKy];
    > >> > foreach (Object prop in valco)
    > >> > {
    > >> > dr[y] = prop.ToString();
    > >> > }
    > >> > }
    > >> > }
    > >> > dt.Rows.Add(dr);
    > >> > }
    > >> >
    > >> > --
    > >> >
    > >> >
    > >> >
    > >>
    > >>
    > >
    > >
    >
    >


  • Next message: Joe Kaplan \(MVP - ADSI\): "Re: listing Object properties from SearchResult"

    Relevant Pages

    • Re: Authenticate Against localhost and AD
      ... >> user names and passwords via a DirectoryEntry bind, ... credentials to ensure that they are not sent in clear text on the network. ... >> For authenticating against local machine accounts, ... but it can definitely be used as an authentication mechanism. ...
      (microsoft.public.dotnet.security)
    • Re: impersonating windows authenticated user?
      ... It is possible to change your IE settings so that Integrated authentication ... always prompts for credentials instead of just passing in the default ... > secure Windows Authentication. ...
      (microsoft.public.dotnet.framework.aspnet.security)
    • Re: Default credentials
      ... > comes up on my client site requires NTLM or Basic authentication? ... > a web browser - I assume it must be something they have set up ... If your receive a Dialog asking for your creds with NTLM auth ... credentials of the current security context. ...
      (microsoft.public.dotnet.framework.aspnet.webservices)
    • Re: Default credentials
      ... > comes up on my client site requires NTLM or Basic authentication? ... > a web browser - I assume it must be something they have set up ... If your receive a Dialog asking for your creds with NTLM auth ... credentials of the current security context. ...
      (microsoft.public.dotnet.framework.webservices)
    • Re: Default credentials
      ... > comes up on my client site requires NTLM or Basic authentication? ... > a web browser - I assume it must be something they have set up ... If your receive a Dialog asking for your creds with NTLM auth ... credentials of the current security context. ...
      (microsoft.public.dotnet.security)