hi,
I look for a solution how to select the user out of the ads like this:
s12345(login-name);firstname secondname
s23456(login-name);firstname secondname
second and firstname can be changed
hope u understand me and can help. I am already infomred about the 2k3 software like ldifde or DSQUERY but i dont get it....
cu later
Page 1 of 1
How to select id and username from ads
#2
Posted 22 May 2006 - 12:51 PM
It is not exactly what you asked for but i was not sure on how to do it like that.
I have made a script with the help of technet
Save the code in a file called export.vbs or something.
And it will show the result in the textfile export.txt like this:
I have made a script with the help of technet
Save the code in a file called export.vbs or something.
'Global variables
Dim oContainer
Dim OutPutFile
Dim FileSystem
'Initialize global variables
Set FileSystem = WScript.CreateObject("Scripting.FileSystemObject")
Set OutPutFile = FileSystem.CreateTextFile("export.txt", True)
Set oContainer=GetObject("LDAP://OU=flappie,DC=contoso,DC=com")
'Enumerate Container
EnumerateUsers oContainer
'Clean up
OutPutFile.Close
Set FileSystem = Nothing
Set oContainer = Nothing
WScript.Echo "Finished"
WScript.Quit(0)
Sub EnumerateUsers(oCont)
Dim oUser
For Each oUser In oCont
Select Case LCase(oUser.Class)
Case "user"
If Not IsEmpty(oUser.distinguishedName) Then
OutPutFile.WriteLine "dn: " & oUser.distinguishedName
End If
If Not IsEmpty(oUser.userPrincipalName) Then
OutPutFile.WriteLine "UserPrincipalName: " & oUser.userPrincipalName
End If
If Not IsEmpty(oUser.sAMAccountName) Then
OutPutFile.WriteLine "Username: " & oUser.sAMAccountName
End If
If Not IsEmpty(oUser.name) Then
OutPutFile.WriteLine "name: " & oUser.Get ("name")
End If
Case "organizationalunit", "container"
EnumerateUsers oUser
End Select
OutPutFile.WriteLine
Next
End Sub
And it will show the result in the textfile export.txt like this:
dn: CN=John Smith,OU=Flappie,DC=contoso,DC=com UserPrincipalName: jsmith@contoso.com Username: jsmith name: John Smith
#3
Posted 23 May 2006 - 03:53 AM
hi, thats nice. but later I want to insert it in a mysql database where I want to part it through a ',' or a ';'. perhaps u know a other solution. that my main target, to get the information about userid and name in a db
#4
Posted 23 May 2006 - 12:37 PM
MAC-DUFF, on May 23 2006, 03:53 AM, said:
hi, thats nice. but later I want to insert it in a mysql database where I want to part it through a ',' or a ';'. perhaps u know a other solution. that my main target, to get the information about userid and name in a db 
Í'll try
Here try this one, the code:
'Global variables
Dim oContainer
Dim OutPutFile
Dim FileSystem
'Initialize global variables
Set FileSystem = WScript.CreateObject("Scripting.FileSystemObject")
Set OutPutFile = FileSystem.CreateTextFile("export3.txt", True)
'change the domain and OU to match yours ofcource;-)
Set oContainer=GetObject("LDAP://OU=flappie,DC=contoso,DC=com")
'Enumerate Container
EnumerateUsers oContainer
'Clean up
OutPutFile.Close
Set FileSystem = Nothing
Set oContainer = Nothing
WScript.Echo "Finished"
WScript.Quit(0)
Sub EnumerateUsers(oCont)
Dim oUser
For Each oUser In oCont
Select Case LCase(oUser.Class)
Case "user"
If Not IsEmpty(oUser.sAMAccountName) Then
OutPutFile.Write oUser.sAMAccountName & ";"
End If
If Not IsEmpty(oUser.name) Then
OutPutFile.WriteLine oUser.Get ("name")
End If
Case "organizationalunit", "container"
EnumerateUsers oUser
End Select
OutPutFile.WriteLine
Next
End Sub
The result:
jdoe;Jane Doe jsmith;John Smith
#5
Posted 24 May 2006 - 07:02 AM
I am a little bit fascinated by your skills. thats excatly what I ve been looking for such a long time. thank u.
now I only have to make some small changes but I ll try it at first allone.
now I only have to make some small changes but I ll try it at first allone.
Share this topic:
Page 1 of 1



Help
Back to top








