Advertisement

11.21.2008 at 04:13AM PST, ID: 23924744
[x]
Attachment Details

ADSI Query and vbscripting

[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

8.7
Zone:

VB Script

Hi,

I've developed a vbscript which queries an access database for user initials and compare them to my active directory, if the user exists in the activedirectory the users title, is added to the same access database.

But for some reason some of the users Title aren't updated in the access database, eventhough the user exists and the field "title" are filled out in the active directory.

Anyone who can explain this ?
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
'on error resume next
dim temp
temp = Main
dim conn
 
Function Main()
    
	Set Conn    = CreateObject("ADODB.Connection")
	Mdb = "telefonbog.mdb"
	Conn.Open "Driver={Microsoft Access Driver (*.mdb)}; DBQ=" & Mdb
	
    DoIt
 
    conn.Close
    Set conn = Nothing
    
End Function
 
Sub DoIt
dim sql
dim rsOpg
 
  Set rsOpg = CreateObject("ADODB.Recordset")
  rsOpg.CursorType = 2  ' adOpenDynamic
  rsOpg.CursorLocation = 3   ' adUseClient
  rsOpg.LockType = 3  ' adLockOptimistic
  rsOpg.Open "select * from medarbejder", conn
  
	Set objNET = CreateObject("Wscript.Network")
 
	Set oRoot = GetObject("LDAP://RootDSE")
	strDomain = oRoot.Get("DefaultNamingContext")
	
  Do while Not rsOpg.EOF	
	
	If len(rsOpg("lokation")) <> "" AND len(rsOpg("initialer")) <= 3 Then
		strUsername = rsOpg("initialer")
		strUserDomain = objNET.UserDomain
			
		Set oCommand = CreateObject("ADODB.Command")
		Set oConnection = CreateObject("ADODB.Connection")
		oConnection.Provider = "ADsDSOObject"
		oConnection.Open = "Active Directory Provider"
		oCommand.ActiveConnection = oConnection
		sQuery = "SELECT Company,Initials,title FROM 'LDAP://" & strDomain & "' WHERE sAMAccountName = '" & strUsername &"'"
		oCommand.CommandText = sQuery
		oCommand.Properties("Page Size") = 100
		oCommand.Properties("Timeout") = 30
		oCommand.Properties("Searchscope") = 2
		oCommand.Properties("Cache Results") = False
		Set oResults = oCommand.Execute
		Msgbox strUsername &" "& oResults("title")			
		If NOT oResults.EOF Then		
			If rsopg("Email") <> "" Then		
				If NOT isNull(oResults("title")) Then				
					Msgbox strUsername &" "& oResults("title")			
					SQL2 = "UPDATE Medarbejder SET Stilling='"&oresults("title")&"' WHERE Initialer='"&strUsername&"'"
					Conn.Execute(SQL2)
				End If
			End If
		End If
	Else
		strUsername = ""
	End If		
  rsOpg.MoveNext
  Loop
 
  rsOpg.Close
  Set rsOpg = Nothing
 
End Sub
 
 
 
Expert Comment by sirbounty:

All comments and solutions are available to Premium Service Members only. Start your 7-day free trial to view the solution to this question.

Already a member? Login to view this solution.

 
 
Expert Comment by BlueDevilFan:

All comments and solutions are available to Premium Service Members only. Start your 7-day free trial to view the solution to this question.

Already a member? Login to view this solution.

 
 
Author Comment by Xcudo:

All comments and solutions are available to Premium Service Members only. Start your 7-day free trial to view the solution to this question.

Already a member? Login to view this solution.

 
 
Expert Comment by BlueDevilFan:

All comments and solutions are available to Premium Service Members only. Start your 7-day free trial to view the solution to this question.

Already a member? Login to view this solution.

 
 
Expert Comment by sirbounty:

All comments and solutions are available to Premium Service Members only. Start your 7-day free trial to view the solution to this question.

Already a member? Login to view this solution.

 
 
Author Comment by Xcudo:

All comments and solutions are available to Premium Service Members only. Start your 7-day free trial to view the solution to this question.

Already a member? Login to view this solution.

 
 
Expert Comment by sirbounty:

All comments and solutions are available to Premium Service Members only. Start your 7-day free trial to view the solution to this question.

Already a member? Login to view this solution.

 
 
Author Comment by Xcudo:

All comments and solutions are available to Premium Service Members only. Start your 7-day free trial to view the solution to this question.

Already a member? Login to view this solution.

 
 
Accepted Solution by sirbounty:

All comments and solutions are available to Premium Service Members only. Start your 7-day free trial to view the solution to this question.

Already a member? Login to view this solution.

 
 
Author Comment by Xcudo:

All comments and solutions are available to Premium Service Members only. Start your 7-day free trial to view the solution to this question.

Already a member? Login to view this solution.

 
 
Expert Comment by sirbounty:

All comments and solutions are available to Premium Service Members only. Start your 7-day free trial to view the solution to this question.

Already a member? Login to view this solution.

 
 
20081119-EE-VQP-45 - Hierarchy / EE_QW_2_20070628