Click here to Skip to main content
14,363,337 members
   

C#

 
QuestionRe: C # Pin
ZurdoDev22-Oct-19 3:59
professionalZurdoDev22-Oct-19 3:59 
AnswerRe: C # Pin
OriginalGriff22-Oct-19 4:32
protectorOriginalGriff22-Oct-19 4:32 
GeneralRe: C # Pin
ZurdoDev22-Oct-19 5:04
professionalZurdoDev22-Oct-19 5:04 
GeneralRe: C # Pin
Dave Kreskowiak22-Oct-19 7:07
mveDave Kreskowiak22-Oct-19 7:07 
GeneralRe: C # Pin
Luc Pattyn22-Oct-19 11:23
professionalLuc Pattyn22-Oct-19 11:23 
GeneralRe: C # Pin
Richard Deeming23-Oct-19 2:25
mveRichard Deeming23-Oct-19 2:25 
GeneralRe: C # Pin
Luc Pattyn23-Oct-19 3:56
professionalLuc Pattyn23-Oct-19 3:56 
QuestionLDAP query to ActiveDirectory being whimsical (search by custom attribute broken) Pin
Super Lloyd21-Oct-19 22:30
memberSuper Lloyd21-Oct-19 22:30 
In our web app we have some Active Directory search happening, using custom attribtue, like so
public DirectoryEntry FindEntry(ADUserId id)
{
    if (id == null || !id.IsValid)
        return null;
    using (var search = new DirectorySearcher(RootEntry))
    {
        if (!string.IsNullOrEmpty(id.SAMAccountName))
        {
            search.Filter = $"(&(objectCategory=person)(objectClass=user)(SAMAccountName={id.SAMAccountName}))";
        }
        else if (!string.IsNullOrEmpty(id.InteractName))
        {
            search.Filter = $"(&(objectCategory=person)(objectClass=user)(interactUsername={id.InteractName}))";
        }
        else
        {
            return null;
        }

        var result = search.FindOne();
        var e = result?.GetDirectoryEntry();
        if (e != null)
        {
            id.SAMAccountName = GetProperty(e, "SAMAccountName") as string;
            id.InteractName = GetProperty(e, "interactUsername") as string;
        }
        return e;
    }
}

I am pretty sure it was working before.
But now if fails when searching by interactUsername... OMG | :OMG: Cry | :((

EDIT / REMARK By "not working" I mean this function now returns null when searching for an existing user, whereas it was returning the user's DirectoryEntry before. Also here is a simpler version which clearly show I am using a custom LDAP attribute in the query
public DirectoryEntry FindEntry(string interactName)
{
    if (interactName == null)
        return null;
    using (var search = new DirectorySearcher(RootEntry))
    {
        search.Filter = $"(&(objectCategory=person)(objectClass=user)(interactUsername={interactName}))";
        var result = search.FindOne();
        return result?.GetDirectoryEntry();
    }
}

What kind of ADFS server change could have broken the search by custom attribute?
My googlefu is not working... Frown | :(

SOLVED
interactUsername that was searched for was 'DEV\ldupont' and as you can see in the code above, there was no escaping of special / reserved characters!
Finally stumbled on the escape character substitution table and that fixed the problem! Smile | :)
Search Filter Syntax - Windows applications | Microsoft Docs
A new .NET Serializer
All in one Menu-Ribbon Bar
Taking over the world since 1371!


modified 23-Oct-19 20:39pm.

SuggestionRe: LDAP query to ActiveDirectory being whimsical (search by custom attribute broken) Pin
Richard MacCutchan21-Oct-19 23:41
protectorRichard MacCutchan21-Oct-19 23:41 
GeneralRe: LDAP query to ActiveDirectory being whimsical (search by custom attribute broken) Pin
Super Lloyd22-Oct-19 2:07
memberSuper Lloyd22-Oct-19 2:07 
GeneralRe: LDAP query to ActiveDirectory being whimsical (search by custom attribute broken) Pin
Richard MacCutchan22-Oct-19 2:31
protectorRichard MacCutchan22-Oct-19 2:31 
Questiona WinForm ToolStripMenuItem quirk ? Pin
BillWoodruff21-Oct-19 5:26
mveBillWoodruff21-Oct-19 5:26 
AnswerRe: a WinForm ToolStripMenuItem quirk ? Pin
Luc Pattyn21-Oct-19 10:14
professionalLuc Pattyn21-Oct-19 10:14 
AnswerRe: a WinForm ToolStripMenuItem quirk ? Pin
Richard Deeming22-Oct-19 1:41
mveRichard Deeming22-Oct-19 1:41 
GeneralRe: a WinForm ToolStripMenuItem quirk ? Pin
BillWoodruff22-Oct-19 1:48
mveBillWoodruff22-Oct-19 1:48 
GeneralRe: a WinForm ToolStripMenuItem quirk ? Pin
Richard Deeming22-Oct-19 2:07
mveRichard Deeming22-Oct-19 2:07 
GeneralRe: a WinForm ToolStripMenuItem quirk ? Pin
BillWoodruff22-Oct-19 20:04
mveBillWoodruff22-Oct-19 20:04 
Question'Access to the path 'F:\System Volume Information' is denied.' Pin
Member 1405587919-Oct-19 9:45
memberMember 1405587919-Oct-19 9:45 
AnswerRe: 'Access to the path 'F:\System Volume Information' is denied.' Pin
Eddy Vluggen19-Oct-19 12:11
mveEddy Vluggen19-Oct-19 12:11 
GeneralRe: 'Access to the path 'F:\System Volume Information' is denied.' Pin
Member 1405587920-Oct-19 3:43
memberMember 1405587920-Oct-19 3:43 
GeneralRe: 'Access to the path 'F:\System Volume Information' is denied.' Pin
Eddy Vluggen20-Oct-19 5:53
mveEddy Vluggen20-Oct-19 5:53 
GeneralRe: 'Access to the path 'F:\System Volume Information' is denied.' Pin
Dave Kreskowiak20-Oct-19 5:59
mveDave Kreskowiak20-Oct-19 5:59 
Questionis any threat (as in sql injection) possible in building a 'RowFilter for a 'DataView Pin
BillWoodruff18-Oct-19 3:05
mveBillWoodruff18-Oct-19 3:05 
AnswerRe: is any threat (as in sql injection) possible in building a 'RowFilter for a 'DataView Pin
Richard Deeming18-Oct-19 3:17
mveRichard Deeming18-Oct-19 3:17 
GeneralRe: is any threat (as in sql injection) possible in building a 'RowFilter for a 'DataView Pin
Luc Pattyn18-Oct-19 4:45
professionalLuc Pattyn18-Oct-19 4:45 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.