none
Error obtaining group names. The specified domain either does not exist or could not be contacted. RRS feed

  • Question

  • I obtained this code from:

    https://support.microsoft.com/en-us/help/316748/how-to-authenticate-against-the-active-directory-by-using-forms-authen

    Copy and pasted everything and changed LDAP path with my verified path and I still get this error about finding group names and domain does not exists. I searched the internet and find everything except the correct answer. 

    Windows 10 Pro compiling from Visual Studio Enterprise 2017.

    Error results when I select logon button after I enter valid domain, username and password. 

    Any help out there? 

    Thanks

    ***UPDATE - Thank you for the possible solutions. I have exhaustively tried pretty much everything even reading that this is not designed to work. Thousands of conditions must be met before this will even begin to consider to work, like it has to be the 3rd Thursday of the month and be raining outside with the wind blowing North by Northwest and only if you name is Steve and you own a dog named Marvin who understands quantum string theory. Then just then it may work even though all code it flawless. I have scrapped this project. Thanks again


    Friday, February 2, 2018 7:21 PM

All replies

  • Are you trying to authenticate an arbitrary user or the user currently using your app? If you're using the current app user then you don't need any of that code. You can simply use the current principal. Note that I don't remember if this gets all the nested groups or just direct members. 

    To ensure you get all groups (or for users other than the current user) you'd want to use GetAuthorizationGroups instead. To get the UserPrincipal you can use the constructor which accepts the context and UN/PWD. The context will be your domain info. The context just requires the type (ContextType.Domain) and domain name.


    Michael Taylor http://www.michaeltaylorp3.net

    • Proposed as answer by Fei HuModerator Wednesday, February 7, 2018 8:58 AM
    Monday, February 5, 2018 4:23 PM
    Moderator
  • That code looks to be using the short domain name. I don't know how you are getting the domain name or what you are using for the root LDAP path, but you may want to try the following:

    systemInfo = CreateObject("ADSystemInfo");
    string shortDomainName = systemInfo.DomainShortName;


    Paul ~~~~ Microsoft MVP (Visual Basic)

    Monday, February 5, 2018 6:20 PM