Re: defaultNamingContext property failing in asp.net
From: Ollie Riches (ollie.riches_at_phoneanalser.net)
Date: 03/17/05
- Next message: David Levine: "Re: Async Socket: How to tell when there is no more data."
- Previous message: James dean: "Slow RichTextBox property"
- In reply to: Joe Kaplan \(MVP - ADSI\): "Re: defaultNamingContext property failing in asp.net"
- Next in thread: Buddy Ackerman: "Re: defaultNamingContext property failing in asp.net"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 17 Mar 2005 09:51:06 -0000
thanks for the info Joe. It was the fact that we were authenticating as
anonymous user and when we set impersonation true for the aspx page then it
all work fine
Cheers
Ollie Riches
"Joe Kaplan (MVP - ADSI)" <joseph.e.kaplan@removethis.accenture.com> wrote
in message news:eydj0llKFHA.2764@tk2msftngp13.phx.gbl...
> Along the lines of the rest of the article that I sent in my last message,
> you may need to provide credentials in your DirectoryEntry as well as a
> server name.
>
> Credentials and a DC to talk to are the two things that ADSI picks up from
> the Windows security context and will supply automatically if you don't
> specify them directly. However, if you don't specify them and your
security
> context isn't a domain account, then those will both fail.
>
> What is likely happening is that you are being authenticated as the
> anonymous user in AD and don't have any permissions to see any objects.
>
> Joe K.
>
> "Ollie Riches" <ollie.riches@phoneanalser.net> wrote in message
> news:uzJS8pkKFHA.3992@TK2MSFTNGP15.phx.gbl...
> > thanks Joe, I do some more searching and found another one of your posts
> > explaining this and it works for accessing the default context but when
I
> > attempt to get the users name ('cn' property) it fails. the code is
shown
> > below.
> >
> > string currentUserName =
> > (((string)Context.User.Identity.Name).Split('\\'))[1];
> > string contextPath = "";
> > using(DirectoryEntry rootEntry = new
> > DirectoryEntry("LDAP://XXXXXX/RootDSE"))
> > {
> > contextPath =
> > rootEntry.Properties["defaultNamingContext"].Value.ToString();
> > }
> > using(DirectoryEntry contextEntry = new DirectoryEntry("LDAP://" +
> > contextPath))
> > using(DirectorySearcher searcher = new DirectorySearcher())
> > {
> > searcher.SearchRoot = contextEntry;
> > searcher.Filter =
> > String.Format("(&(objectCategory=person)(samAccountName={0}))",
> > currentUserName);
> > searcher.PropertiesToLoad.Add("cn");
> > searcher.SearchScope = SearchScope.Subtree;
> > SearchResult result = searcher.FindOne();
> > return result.Properties["cn"][0].ToString();
> > }
> >
> > When impersonation was used in asp.net then it all works perfectly fine
as
> > I
> > expected but using impersonation defeats what I am try to achieve.
> >
> >
> >
> >
> > "Joe Kaplan (MVP - ADSI)" <joseph.e.kaplan@removethis.accenture.com>
wrote
> > in message news:#jpM27jKFHA.3992@TK2MSFTNGP15.phx.gbl...
> >> The issue is probably serverless binding (not putting a server name in
> > your
> >> binding string). That only works if your current thread is running
under
> > a
> >> domain account.
> >>
> >> Trying putting the DNS name of a domain controller in there
> >> (LDAP://server.com/RootDSE) and see if that fixes it. If so, that's
your
> >> problem.
> >>
> >> http://support.microsoft.com/default.aspx?scid=kb;en-us;329986
> >>
> >> Joe K.
> >>
> >> "Ollie Riches" <ollie.riches@phoneanalser.net> wrote in message
> >> news:eE0%23HAhKFHA.1948@TK2MSFTNGP14.phx.gbl...
> >> >I am trying to access an AD from asp.net, I am getting the 'famous'
"The
> >> > specified domain either does not exist or could not be contacted"
> >> > exception
> >> > with a HR = 0x08007054b
> >> >
> >> > the code (C# .Net) is as follows:
> >> >
> >> > DirectoryEntry rootEntry = new DirectoryEntry("LDAP://RootDSE");
> >> > string contextPath =
> >> > rootEntry.Properties["defaultNamingContext"].Value.ToString();
> >> > rootEntry.Dispose();
> >> > DirectoryEntry contextEntry = new DirectoryEntry("LDAP://" +
> > contextPath);
> >> >
> >> > I know this code works and as far as I know I should be able to
> >> > access\query
> >> > the root but it fails. So is it a permissions issue with asp.net or
the
> >> > domain configuration.
> >> >
> >> >
> >> > Cheers
> >> >
> >> > Ollie Riches
> >> > http://www.phoneanalyser.net
> >> >
> >> > Disclaimer: Opinions expressed in this forum are my own, and not
> >> > representative of my employer.
> >> > I do not answer questions on behalf of my employer. I'm just a
> > programmer
> >> > helping programmers.
> >> >
> >> >
> >>
> >>
> >
> >
>
>
- Next message: David Levine: "Re: Async Socket: How to tell when there is no more data."
- Previous message: James dean: "Slow RichTextBox property"
- In reply to: Joe Kaplan \(MVP - ADSI\): "Re: defaultNamingContext property failing in asp.net"
- Next in thread: Buddy Ackerman: "Re: defaultNamingContext property failing in asp.net"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|