473,385 Members | 1,782 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Wildcard * not working in ldap for SOME attributes..?

374 256MB
Im back... with more ActiveDirectory questions.

Firslty I will show you my output:

Expand|Select|Wrap|Line Numbers
  1. Output 1 - Search based on department name:
  2.  
  3. The filter string: (&(objectClass=*)(departmentText=Business*))
  4. Records returned: 0 
  5.  
  6. Output 2 - Search based on last name of person:
  7. The filter string:
  8. (&(objectClass=*)(LastName=Mobb*))
  9. Records returned: 1 
  10. Department: Business Excellence
The issue is that basically the wildcard operator * seems to not be working correctly when running my query function against an active directory.

If I run a search of a partial last name where the attribute is lastname=mobb* it will find me, and also as shown in the above code I can output my exact department as being "Business Excellence" as shown in the second output.

If I run a search of a partial departmet such as departmenttext=Buss* it will not find any records as shown in the first output.

However, If I remove the wildcard from the department search and use the EXACT name so: departmenttext=Business Excellence I get all members of my department to show.

Does anyone have any idea why the wildcard does not work for this attribute? Infact I have just found that it does not work on a second, whilst the other 14 attributes it works correctly! I really cant imagine that some attributes are not searchable via a wildcard in AD.

My full code is below:

Expand|Select|Wrap|Line Numbers
  1. Public Function UserInfoo(SearchString As String, SearchBase As String)
  2.  
  3. Dim rs As ADODB.Recordset
  4. Dim sBase As String
  5. Dim sFilter As String
  6. Dim sDomain As String
  7. Dim sAttribs As String
  8. Dim sDepth As String
  9. Dim sQuery As String
  10. Dim sAns As String
  11. Dim user As IADsUser
  12. Dim counter As Integer
  13. Dim strHeaders As String
  14. Dim Searcher As String
  15.  
  16. On Error GoTo ErrHandler:
  17.  
  18. 'Select our Actual SearchBase based on incoming string supplied from form
  19. Select Case SearchBase
  20.     Case "Last Name"
  21.         Searcher = "LastName"
  22.     Case "First Name"
  23.         Searcher = "givenName"
  24.     Case "Gender"
  25.         Searcher = "gender"
  26.     Case "Company"
  27.         Searcher = "company"
  28.     Case "Department"
  29.         Searcher = "departmentText"
  30.     Case "SCD ID"
  31.         Searcher = "scdid"
  32.     Case "Function"
  33.         Searcher = "mainfunction"
  34.     Case "Cost Unit"
  35.         Searcher = "costlocation"
  36.     Case "Nickname"
  37.         Searcher = "nickname"
  38.     Case "Organisation"
  39.         Searcher = "o"
  40.     Case "Locality"
  41.         Searcher = "localitynational"
  42.     Case "Phone"
  43.         Searcher = "mobile"
  44.     Case "GID"
  45.         Searcher = "tcgid"
  46.     Case "Email"
  47.         Searcher = "mail"
  48.     Case Else
  49.         MsgBox "You must select a parameter to base your search on.", vbInformation, "Error.."
  50.         Exit Function
  51. End Select
  52.  
  53.  
  54.  
  55. 'create and setup our ado connection with anonymous connectivity
  56. Set ado = CreateObject("ADODB.Connection")
  57.     ado.Provider = "ADSDSOObject"
  58.     ado.Properties("User ID") = ""
  59.     ado.Properties("Password") = ""
  60.     ado.Properties("Encrypt Password") = False
  61.     ado.Open "ADS-Anon-Search"
  62.  
  63. 'The basic directory we want to look in to, domain filtering down
  64. servername = "scd2ldap.mycompany.net/l=NUT S,ou=E F,o=mycompany,c=GB"
  65.  
  66. 'Create LDAP connection string for directory based on server address
  67. sBase = "<LDAP://" & servername & ">"
  68.  
  69. 'Look within all objectclasses and search for our lastname attribute using a like clause.
  70. sFilter = "(&(objectClass=*)(" & Searcher & "=" & SearchString & "*" & "))"
  71. 'Attributes
  72. sAttribs = "adsPath"
  73. 'Depth to look in to when finding attributes, subTree of user found in search
  74. sDepth = "subTree"
  75.  
  76. 'Overall query string to run for our connection
  77. sQuery = sBase & ";" & sFilter & ";" & sAttribs & ";" & sDepth
  78. 'Set headers of listbox ready to be populated with data returned from query
  79. strHeaders = "Given Name;Last Name;Gender;Company;Department;Locality;E mail;function;phone;GID;CN;costunit;nickname;title;organisation;scdId"
  80.  
  81. 'Set counter to 0 for counting number of times we have run through our function loop
  82. counter = 0
  83.  
  84. 'Set recordset equal to that of the executed query, recordset will contain all data returned
  85. Set rs = ado.Execute(sQuery)
  86. 'Implement the headers for the listbox
  87.     Forms.form1.listbox1.RowSource = strHeaders
  88.  
  89. 'Start our do until loop based on number of records in our recordset against number of times looped
  90. Do Until counter = rs.RecordCount
  91.     Set user = GetObject(rs("adsPath"))
  92.     sAns = ""
  93.         With user
  94.             On Error Resume Next
  95.             sAns = sAns & Trim(StripString(.givenName)) & ";" & Trim(StripString(.LastName)) & ";" & Trim(.gender) & ";" & Trim(StripString(.company)) & ";" & Trim(StripString(.departmenttext)) & ";" & Trim(StripString(.localitynational)) & ";" & Trim(StripString(.mail)) & ";" & Trim(StripString(.mainFunction)) & ";" & Trim(StripString(.mobile)) & ";" & Trim(StripString(.tcgid)) & ";" & Trim(StripString(.cn)) & ";" & Trim(StripString(.costlocation)) & ";" & Trim(StripString(.nickname)) & ";" & Trim(StripString(.Title)) & ";" & Trim(StripString(.o)) & ";" & Trim(StripString(.scdid)) & ";"
  96.                 End With
  97.     Forms.form1.listbox1.AddItem (sAns)
  98.     rs.MoveNext
  99.     counter = counter + 1
  100.  
  101.  
  102. Loop
  103.  
  104. 'Success
  105. Completed:
  106.     If Not rs Is Nothing Then
  107.         If rs.State <> 0 Then rs.Close
  108.         Set rs = Nothing
  109.     End If
  110.  
  111.     If Not ado Is Nothing Then
  112.         If ado.State <> 0 Then ado.Close
  113.         Set ado = Nothing
  114.     End If
  115.  
  116.     Exit Function
  117.  
  118.  
  119. ErrHandler:
  120.     If Not rs Is Nothing Then
  121.         If rs.State <> 0 Then rs.Close
  122.         Set rs = Nothing
  123.     End If
  124.  
  125.     If Not ado Is Nothing Then
  126.         If ado.State <> 0 Then ado.Close
  127.         Set ado = Nothing
  128.     End If
  129.  
  130.     MsgBox Err.Description & " " & Err.Number
  131.  
  132.     Resume Completed
  133.  
  134.  
  135. End Function
  136.  
Nov 29 '10 #1
1 3458
munkee
374 256MB
I have done a little testing and if I remove the wildcard * from my function and then just add it in to my input into the function I can do the following:

Removing all *'s and just running direct search for Business Excellence returns 5 correct records

Adding in a * to the end of Business Excellence returns 0 records

Adding in partial department name such as Business with a wild card returns 0 records.

So it seems the wildcard simply will not work on the attribute. I have checked the attribute properties and it seems to say it is a Text type, which all the other searchables are also.
Nov 29 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Alex Hunsley | last post by:
I'm using a mysql monitor under cygwin (on win xp) to do a 'load data infile' to put some data into a mysql database (I'm using the xampp bundle).. My problem is that I have a four line CSV file...
1
by: Edlueze | last post by:
I have a number of forms with large textboxes for the purposes of editing memo fields, and just recently I've noticed some bizarre behavior. For some textboxes the END and HOME keys do nothing,...
1
by: Christian | last post by:
Hi, I'm developing a customcontrol and try to add some design-time support for my control by using attributes. Unfortunately only the 'CategoryAttribute' works well when I drag my control on...
2
by: PrinceMhul | last post by:
var objListBox = document.getElementById('catalist'); var val = objListBox.value; var txt = dyevalue00.value; document.getElementById(val).value = txt; To explain real quick, this is for a...
7
by: vinsim24 | last post by:
Hi all, the code where i am finding a problem is as follows: <html> <head> <script> function fun1(){ window.document.formName.action="/someServlet"; window.document.formName.submit();
3
by: bnashenas1984 | last post by:
Hi everyone I'v been programming a simple task and process manager which is working fine now but the problem is that my program does NOT work on some computers. I think it must have something to do...
0
by: billelev | last post by:
I am using the following code to find the last row that contains data, within a particular column on a spreadsheet. Dim ws As Worksheet Set ws = Worksheets(Me.ChartDataSheetName)...
3
by: musicgold | last post by:
Hi, I am new in XML. But I have done coding in VBA, C, and HTML. I am using VBA to extract data from an xml file. I use Xpathbuilder to generate Xpath queries for my work. However, some Xpath...
2
dlite922
by: dlite922 | last post by:
Hey guys, Sometimes it's the most simplest things in life that drive you insane. I'm no complete MySQL noob and I'm not doing anything fancy by any stretch. My table contains two date-times: ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.