MAC-DUFF Posted May 21, 2006 Share Posted May 21, 2006 hi,I look for a solution how to select the user out of the ads like this:s12345(login-name);firstname secondnames23456(login-name);firstname secondnamesecond and firstname can be changedhope 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 Link to comment Share on other sites More sharing options...
Zartach Posted May 22, 2006 Share Posted May 22, 2006 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.'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 NextEnd SubAnd it will show the result in the textfile export.txt like this: dn: CN=John Smith,OU=Flappie,DC=contoso,DC=comUserPrincipalName: jsmith@contoso.comUsername: jsmithname: John Smith Link to comment Share on other sites More sharing options...
MAC-DUFF Posted May 23, 2006 Author Share Posted May 23, 2006 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 Link to comment Share on other sites More sharing options...
Zartach Posted May 23, 2006 Share Posted May 23, 2006 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 NextEnd SubThe result: jdoe;Jane Doejsmith;John Smith Link to comment Share on other sites More sharing options...
MAC-DUFF Posted May 24, 2006 Author Share Posted May 24, 2006 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. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now