UniStuttgart-VISUS / Visus.LdapAuthentication

LDAP authentication middleware for ASP.NET Core
MIT License
24 stars 8 forks source link

How to specify more than one SearchBase ? #7

Closed kamilk91 closed 9 months ago

kamilk91 commented 11 months ago

Hello. I have case that my users are stored in 2 SearchBase locations. How do i create something like:

 "SearchBase": "(OU=01-Level,OU=Utilisateurs,DC=example,DC=com) && (OU=01-AnotherLevel,OU=Utilisateurs,DC=anotherexample,DC=com)",

that is looking for users in both locations?

crowbar27 commented 10 months ago

Unfortunately, this is not supported right now. I need to think a bit how to change this without breaking existing deployments (the obvious option would be making the SearchBase an array, but that would require all existing app settings to be adjusted).

crowbar27 commented 9 months ago

@kamilk91 Can you check whether the changes in master address your problem? You should replace

"SearchBase": "(OU=01-Level,OU=Utilisateurs,DC=example,DC=com) && (OU=01-AnotherLevel,OU=Utilisateurs,DC=anotherexample,DC=com)"

by

"SearchBases": [
    {
        "DistinguishedName": "OU=01-Level,OU=Utilisateurs,DC=example,DC=com"
    },
    {
        "DistinguishedName": "OU=01-AnotherLevel,OU=Utilisateurs,DC=anotherexample,DC=com"
    }
]

It is important that you replace SearchBase and, if set, IsSubtree and have both OUs in SearchBases. If both are set, SearchBases will overrule SearchBase.

kamilk91 commented 9 months ago

@crowbar27 thank you a lot for your response. Unfortunatly, project is very strict and internal, so i didn't had access to it last month.

Im sorry i didn't replied, i will test it and close issue. Thank you for your work!

crowbar27 commented 9 months ago

@kamilk91 Please note that I have changed the syntax slightly in main. I think the dictionary is more convenient to specify in JSON, albeit it requires to specify the scope explicitly. You configuration now looks like

"SearchBases": {
    "OU=01-Level,OU=Utilisateurs,DC=example,DC=com": "Subtree",
    "OU=01-AnotherLevel,OU=Utilisateurs,DC=anotherexample,DC=com": "Subtree"
}

Could you please drop a note whether this is the feature you are looking for such that I can push the new nuget package?