@@ -218,6 +218,9 @@ private static LdapConfig SetConfigValues(LdapConfig target, LdapConfig source)
218218
219219 if ( target . IgnoreWarnings == null )
220220 target . IgnoreWarnings = source . IgnoreWarnings ;
221+
222+ if ( target . TokenType == null )
223+ target . TokenType = source . TokenType ;
221224
222225 if ( target . AttributeTypes == null )
223226 target . AttributeTypes = new Dictionary < string , LdapAttributeTypes > ( StringComparer . OrdinalIgnoreCase ) ;
@@ -275,15 +278,17 @@ public static LdapCrypto ApplyDefaulsAndValidate(LdapCrypto crypto)
275278 return crypto ;
276279 }
277280
278- public static string GetSearchString ( LdapRequest request )
281+ public static string GetSearchString ( LdapRequest request , string searchValue = null , string SearchBase = null , bool flag = false )
279282 {
280283 string searchFilter = null ;
281284
282285 if ( request . ObjectType == null )
283286 searchFilter = request . SearchValue ;
287+ else if ( request . ObjectType == null && flag == true )
288+ searchFilter = searchValue ;
284289 else
285290 {
286- string id = GetIdentitySearchString ( request ) ;
291+ string id = GetIdentitySearchString ( request , searchValue , SearchBase , flag ) ;
287292
288293 if ( request . ObjectType == ObjectType . Ou )
289294 searchFilter = $ "(&(objectCategory=OrganizationalUnit){ id } )";
@@ -302,10 +307,12 @@ public static string GetSearchString(LdapRequest request)
302307 return searchFilter ;
303308 }
304309
305- public static string GetIdentitySearchString ( LdapRequest request )
310+ public static string GetIdentitySearchString ( LdapRequest request , string searchVal = null , string SearchBase = null , bool flag = false )
306311 {
307312 string identity = null ;
308313 string searchValue = request . SearchValue ;
314+ if ( flag == true )
315+ searchValue = searchVal ;
309316 Guid g = Guid . Empty ;
310317 string dnRegexString = @"^\s*?(cn\s*=|ou\s*=|dc\s*=)" ;
311318
@@ -372,15 +379,11 @@ public static bool ContainsKnownDomain(string value)
372379 return rc ;
373380 }
374381
375- // public static void CheckforError(LdapRequest request){
376- // Regex test = new(@"\([^)]*\)");
377- // for (int i = 0; i < request.Union.Count; i++){
378- // var index = request.Union.ElementAt(i);
379- // bool result = test.IsMatch(index["searchValue"]);
380- // if(!result){
381- // throw new Exception(String.Format("Error: Search Value in index: {0} is not properly formatted", i));
382- // }
383- // }
384- // }
382+ public static string CheckforError ( LdapRequest request , string searchValue , string SearchBase ) {
383+ if ( Regex . IsMatch ( searchValue , @"\([^)]*\)" ) == false ) {
384+ searchValue = LdapUtils . GetSearchString ( request , searchValue , SearchBase , true ) ;
385+ }
386+ return searchValue ;
387+ }
385388 }
386389 }
0 commit comments