System.DirectoryServices

Ask a Question related to ASP.NET Security, Design and Development.

  1. #1

    Default System.DirectoryServices

    I have a few pages which authenticate a user to our site.

    Checking a login and password with syntax as below:

    Dim entry As New DirectoryEntry(_path, domainAndUsername, PWD)

    My problem is I can only do this if I elevate the anonymous user to
    ADMINISTRATOR of my domain.

    Should my ASPX page have to be running the ADMIN account to use this
    namespace.
    Another task I need is to enumerate users in a GROUP using this
    namespace.
    That also only works with the ADMIN account.

    Thanks,
    Brian
    Brian Guest

  2. Similar Questions and Discussions

    1. Using System.DirectoryServices from within webservice
      I am trying to access to my AD using LDAP in a ASP.NET web service. I use System.DirectoryServices.DirectoryEntry. However, when I try to open...
    2. System.DirectoryServices - The server is not operational
      I have an asp.net web application written in c# that uses Forms Authentication to authenticate against our Active Directory. I based the...
    3. System.Directoryservices getting TxIsolationLevel exeption?
      Hi I am trying to add a user to a group in Active Directory using System.Directory Services But when I CommitChanges() I get the following...
    4. System.DirectoryServices missing reference
      Hi there, here a typical "bloody newbie" question: I am programming a simple Webservice who should add a user to AD. My programming...
    5. Imports 'System.DirectoryServices' cannot be found.
      Hello, I'm getting the following error message: "Compiler Error Message: BC30466: Namespace or type 'DirectoryServices' for the Imports...
  3. #2

    Default Re: System.DirectoryServices

    No, you should be able to use the user's credentials to bind. Is this
    Active Directory or an NT4 domain? Are you using the LDAP provider (your
    _path variable doesn't make this clear)? What is the path you are using?

    Joe K.

    "Brian" <bonei@vafb.com> wrote in message
    news:d2129775.0406011420.17d94784@posting.google.c om...
    > I have a few pages which authenticate a user to our site.
    >
    > Checking a login and password with syntax as below:
    >
    > Dim entry As New DirectoryEntry(_path, domainAndUsername, PWD)
    >
    > My problem is I can only do this if I elevate the anonymous user to
    > ADMINISTRATOR of my domain.
    >
    > Should my ASPX page have to be running the ADMIN account to use this
    > namespace.
    > Another task I need is to enumerate users in a GROUP using this
    > namespace.
    > That also only works with the ADMIN account.
    >
    > Thanks,
    > Brian

    Joe Kaplan \(MVP - ADSI\) Guest

  4. #3

    Default Re: System.DirectoryServices

    Thanks,
    I am using syntax "LDAP://" and then the name of the user to get his
    SAMAccountName, etc..
    We have found this code works differently on different servers here.
    Could be my question is voided by that. I have tried making myself the
    anonymous user and gotten some success as well on some servers.
    The consistent problem is executing the looping over users in a
    group as follows:

    Dim de As System.DirectoryServices.DirectoryEntry = _
    New DirectoryServices.DirectoryEntry(adPath,
    domainAndUsername, strPassword)
    Dim ds As DirectorySearcher = New DirectorySearcher(de)
    ds.Filter = "((cn=" & strGroupName & "))"
    Dim dResults As SearchResultCollection = ds.FindAll()
    For Each dResult As SearchResult In dResults
    Dim resultPropColl As ResultPropertyCollection =
    dResult.Properties
    For Each memberItem As Object In resultPropColl("member")
    Dim foundUser As DirectoryEntry = _
    New DirectoryEntry("LDAP://" &
    memberItem.ToString(), domainAndUsername, strPassword)
    Dim userProps As PropertyCollection =
    foundUser.Properties
    If Not IsNothing(userProps("SAMAccountName").Value)
    Then
    stSorted.Add(userProps("SAMAccountName").Value,
    userProps("Name").Value)
    End If
    Next
    Next

    This chunk of code is the one that fails upon moving to varying
    servers.
    Is it possible that FINDALL requires more permission than simply "New
    Entry"?



    "Joe Kaplan \(MVP - ADSI\)" <joseph.e.kaplan@removethis.accenture.com> wrote in message news:<eRpTe7ESEHA.3628@TK2MSFTNGP12.phx.gbl>...
    > No, you should be able to use the user's credentials to bind. Is this
    > Active Directory or an NT4 domain? Are you using the LDAP provider (your
    > _path variable doesn't make this clear)? What is the path you are using?
    >
    > Joe K.
    >
    > "Brian" <bonei@vafb.com> wrote in message
    > news:d2129775.0406011420.17d94784@posting.google.c om...
    > > I have a few pages which authenticate a user to our site.
    > >
    > > Checking a login and password with syntax as below:
    > >
    > > Dim entry As New DirectoryEntry(_path, domainAndUsername, PWD)
    > >
    > > My problem is I can only do this if I elevate the anonymous user to
    > > ADMINISTRATOR of my domain.
    > >
    > > Should my ASPX page have to be running the ADMIN account to use this
    > > namespace.
    > > Another task I need is to enumerate users in a GROUP using this
    > > namespace.
    > > That also only works with the ADMIN account.
    > >
    > > Thanks,
    > > Brian
    Brian Guest

  5. #4

    Default Re: System.DirectoryServices

    Do you also specify a server or domain in the LDAP path? If the current
    security context is a local machine user, then ADSI may not be able to
    automatically determine a domain controller to use, so the bind might not
    work. I'd try that first.

    LDAP://servername.com/dn


    Also, two other things:
    - You should generally ALWAYS use AuthenticationTypes.Secure as the 4th
    parameter in your DirectoryEntry constructors when using AD. This makes
    sure that SSPI is used to exchange credentials instead of passing your
    password plaintext on the network. There is really no reason to not do
    this. This advice doesn't necessarily apply to other LDAP directories
    though.
    - Don't forget to call dispose on all of your IDisposable objects
    (DirectoryEntry, DirectorySearcher, SearchResultCollection) or you may leak
    resources. This is especially important in the current version of the .NET
    Framework, the Finalize method on DirectoryEntry doesn't actually close the
    underlying COM object, so relying on the garbage collector/finalizer thread
    to clean these up won't work.

    Joe K.

    "Brian" <bonei@vafb.com> wrote in message
    news:d2129775.0406091131.5fc529ec@posting.google.c om...
    > Thanks,
    > I am using syntax "LDAP://" and then the name of the user to get his
    > SAMAccountName, etc..
    > We have found this code works differently on different servers here.
    > Could be my question is voided by that. I have tried making myself the
    > anonymous user and gotten some success as well on some servers.
    > The consistent problem is executing the looping over users in a
    > group as follows:
    >
    > Dim de As System.DirectoryServices.DirectoryEntry = _
    > New DirectoryServices.DirectoryEntry(adPath,
    > domainAndUsername, strPassword)
    > Dim ds As DirectorySearcher = New DirectorySearcher(de)
    > ds.Filter = "((cn=" & strGroupName & "))"
    > Dim dResults As SearchResultCollection = ds.FindAll()
    > For Each dResult As SearchResult In dResults
    > Dim resultPropColl As ResultPropertyCollection =
    > dResult.Properties
    > For Each memberItem As Object In resultPropColl("member")
    > Dim foundUser As DirectoryEntry = _
    > New DirectoryEntry("LDAP://" &
    > memberItem.ToString(), domainAndUsername, strPassword)
    > Dim userProps As PropertyCollection =
    > foundUser.Properties
    > If Not IsNothing(userProps("SAMAccountName").Value)
    > Then
    > stSorted.Add(userProps("SAMAccountName").Value,
    > userProps("Name").Value)
    > End If
    > Next
    > Next
    >
    > This chunk of code is the one that fails upon moving to varying
    > servers.
    > Is it possible that FINDALL requires more permission than simply "New
    > Entry"?
    >
    >
    >
    > "Joe Kaplan \(MVP - ADSI\)" <joseph.e.kaplan@removethis.accenture.com>
    wrote in message news:<eRpTe7ESEHA.3628@TK2MSFTNGP12.phx.gbl>...
    > > No, you should be able to use the user's credentials to bind. Is this
    > > Active Directory or an NT4 domain? Are you using the LDAP provider
    (your
    > > _path variable doesn't make this clear)? What is the path you are
    using?
    > >
    > > Joe K.
    > >
    > > "Brian" <bonei@vafb.com> wrote in message
    > > news:d2129775.0406011420.17d94784@posting.google.c om...
    > > > I have a few pages which authenticate a user to our site.
    > > >
    > > > Checking a login and password with syntax as below:
    > > >
    > > > Dim entry As New DirectoryEntry(_path, domainAndUsername, PWD)
    > > >
    > > > My problem is I can only do this if I elevate the anonymous user to
    > > > ADMINISTRATOR of my domain.
    > > >
    > > > Should my ASPX page have to be running the ADMIN account to use this
    > > > namespace.
    > > > Another task I need is to enumerate users in a GROUP using this
    > > > namespace.
    > > > That also only works with the ADMIN account.
    > > >
    > > > Thanks,
    > > > Brian

    Joe Kaplan \(MVP - ADSI\) Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139