How to list all the Fields for an Active Directory Object

How do I list all the fields that an Active Directory object contains? I know the most common ones, but would like to enumerate through all the fields and obtain the type of fields and their values...

Here is my complete code - I only put snippets so that the post was not too huge...
Option Explicit
Const ADS_SCOPE_SUBTREE = 2
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Dim adoCommand, adoConnection, adoRecordSet
Dim dtmDate, dtmValue
Dim j
Dim lngBias, lngBiasKey, lngHigh, lngLow, lngValue
Dim objADObject, objClass, objDate, objFile, objFSO, objRootDSE, objShell
Dim pathToScript
Dim strAdsPath, strConfig, strDNSDomain, strHex, strItem, strProperty, strValue
Dim strFilter, strQuery
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objShell = CreateObject("Wscript.Shell")
pathToScript = objShell.CurrentDirectory
Set objFile = objFSO.CreateTextFile(pathToScript & "\TestAD.csv")
' Determine Time Zone bias in local registry.
' This bias changes with Daylight Savings Time.
lngBiasKey = objShell.RegRead("HKLM\System\CurrentControlSet\Control\TimeZoneInformation\ActiveTimeBias")
If (UCase(TypeName(lngBiasKey)) = "LONG") Then
lngBias = lngBiasKey
ElseIf (UCase(TypeName(lngBiasKey)) = "VARIANT()") Then
lngBias = 0
For j = 0 To UBound(lngBiasKey)
lngBias = lngBias + (lngBiasKey(j) * 256^j)
Next
End If
' Determine configuration context and DNS domain from RootDSE object.
Set objRootDSE = GetObject("LDAP://RootDSE")
strConfig = objRootDSE.Get("configurationNamingContext")
strDNSDomain = objRootDSE.Get("defaultNamingContext")
Set adoCommand = CreateObject("ADODB.Command")
Set adoConnection = CreateObject("ADODB.Connection")
adoConnection.Provider = "ADsDSOObject"
adoConnection.Open "Active Directory Provider"
adoCommand.ActiveConnection = adoConnection
adoCommand.CommandText = "SELECT * FROM 'LDAP://" & strDNSDomain & "'WHERE objectClass=user'"
adoCommand.Properties("Page Size") = 1000
adoCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
Set adoRecordSet = adoCommand.Execute
Set adoRecordSet = adoCommand.Execute
adoRecordSet.MoveFirst
Do Until adoRecordSet.EOF
strAdsPath = adoRecordSet.Fields("ADsPath").Value
' Bind to Active Directory object specified.
Set objADObject = GetObject(strAdsPath)
Set objClass = GetObject(objADObject.Schema)
' Write which object is grabbed from AD
objFile.Write(Replace(strAdsPath, ",", ";;;"))
' Enumerate mandatory object properties.
For Each strProperty In objClass.MandatoryProperties
On Error Resume Next
strValue = objADObject.Get(strProperty)
If (Err.Number = 0) Then
On Error GoTo 0
If (TypeName(strValue) = "String") Or (TypeName(strValue) = "Long") Or (TypeName(strValue) = "Date") Then
objFile.Write("," & strProperty & "|||" & Replace(CStr(strValue), ",", ";;;"))
ElseIf (TypeName(strValue) = "Byte()") Then
strHex = OctetToHexStr(strValue)
objFile.Write("," & strProperty & "|||" & CStr(strHex))
ElseIf (TypeName(strValue) = "Variant()") Then
For Each strItem In strValue
On Error Resume Next
objFile.Write("," & strProperty & "|||" & Replace(CStr(strItem), ",", ";;;"))
If (Err.Number <> 0) Then
On Error GoTo 0
objFile.Write("," & strProperty & "|||Value cannot be displayed")
End If
On Error GoTo 0
Next
ElseIf (TypeName(strValue) = "Boolean") Then
objFile.Write("," & strProperty & "|||" & CBool(strValue))
Else
objFile.Write("," & strProperty & "|||Type:" & TypeName(strValue))
End If
Else
Err.Clear
sColl = objADObject.GetEx(strProperty)
If (Err.Number = 0) Then
For Each strItem In sColl
objFile.Write("," & strProperty & "|||" & CStr(strItem))
If (Err.Number <> 0) Then
objFile.Write("," & strProperty & "|||Value cannot be displayed")
End If
Next
On Error GoTo 0
Else
Err.Clear
Set objDate = objADObject.Get(strProperty)
If (Err.Number = 0) Then
lngHigh = objDate.HighPart
If (Err.Number = 0) Then
lngLow = objDate.LowPart
If (lngLow < 0) Then
lngHigh = lngHigh + 1
End If
lngValue = (lngHigh * (2 ^ 32)) + lngLow
If (lngValue > 120000000000000000) Then
dtmValue = #1/1/1601# + (lngValue / 600000000 - lngBias) / 1440
On Error Resume Next
dtmDate = CDate(dtmValue)
If (Err.Number <> 0) Then
objFile.Write("," & strProperty & "|||<Never>")
Else
objFile.Write("," & strProperty & "|||" & CStr(dtmDate))
End If
Else
objFile.Write("," & strProperty & "|||" & FormatNumber(lngValue, 0))
End If
Else
objFile.Write("," & strProperty & "|||Value cannot be displayed")
End If
Else
On Error GoTo 0
objFile.Write("," & strProperty)
End If
On Error GoTo 0
End If
End If
Next
' Enumerate optional object properties.
For Each strProperty In objClass.OptionalProperties
On Error Resume Next
strValue = objADObject.Get(strProperty)
If (Err.Number = 0) Then
On Error GoTo 0
If (TypeName(strValue) = "String") Then
objFile.Write("," & strProperty & "|||" & Replace(CStr(strValue), ",", ";;;"))
ElseIf (TypeName(strValue) = "Long") Then
objFile.Write("," & strProperty & "|||" & Replace(CStr(strValue), ",", ";;;"))
ElseIf (TypeName(strValue) = "Date") Then
objFile.Write("," & strProperty & "|||" & Replace(CStr(strValue), ",", ";;;"))
ElseIf (TypeName(strValue) = "Byte()") Then
strHex = OctetToHexStr(strValue)
objFile.Write("," & strProperty & "|||" & CStr(strHex))
ElseIf (TypeName(strValue) = "Variant()") Then
For Each strItem In strValue
On Error Resume Next
objFile.Write("," & strProperty & "|||" & Replace(CStr(strItem), ",", ";;;"))
If (Err.Number <> 0) Then
On Error GoTo 0
objFile.Write("," & strProperty & "|||Value cannot be displayed")
End If
On Error GoTo 0
Next
ElseIf (TypeName(strValue) = "Boolean") Then
objFile.Write("," & strProperty & "|||" & CBool(strValue))
Else
objFile.Write("," & strProperty & "|||Type:" & TypeName(strValue))
End If
Else
Err.Clear
sColl = objADObject.GetEx(strProperty)
If (Err.Number = 0) Then
For Each strItem In sColl
objFile.Write("," & strProperty & "|||" & CStr(strItem))
If (Err.Number <> 0) Then
objFile.Write("," & strProperty & "|||Value cannot be displayed")
End If
Next
On Error GoTo 0
Else
Err.Clear
Set objDate = objADObject.Get(strProperty)
If (Err.Number = 0) Then
lngHigh = objDate.HighPart
If (Err.Number = 0) Then
lngLow = objDate.LowPart
If (lngLow < 0) Then
lngHigh = lngHigh + 1
End If
lngValue = (lngHigh * (2 ^ 32)) + lngLow
If (lngValue > 120000000000000000) Then
dtmValue = #1/1/1601# + (lngValue / 600000000 - lngBias) / 1440
On Error Resume Next
dtmDate = CDate(dtmValue)
If (Err.Number <> 0) Then
objFile.Write("," & strProperty & "|||<Never>")
Else
objFile.Write("," & strProperty & "|||" & CStr(dtmDate))
End If
Else
objFile.Write("," & strProperty & "|||" & lngValue)
End If
Else
objFile.Write("," & strProperty & "|||Value cannot be displayed")
End If
Else
On Error GoTo 0
objFile.Write("," & strProperty & "||| ")
End If
On Error GoTo 0
End If
End If
Next
objFile.WriteLine("")
adoRecordSet.MoveNext
Loop
objFile.Close
' Function to convert OctetString (Byte Array) to a hex string.
Function OctetToHexStr(arrbytOctet)
Dim k
OctetToHexStr = ""
For k = 1 To Lenb(arrbytOctet)
OctetToHexStr = OctetToHexStr _
& Right("0" & Hex(Ascb(Midb(arrbytOctet, k, 1))), 2)
Next
End Function
I have been able to obtain all the Computer, Contact, Group and OU objects without issue with this code...

Similar Messages

  • How to list all the fields under an Infotype!

    Hi
    I need a list of fields under an Infotype, used the following link to list them but unsuccesful, is there any other way I can list the infotype feilds.
    Re: Infotype 0002 all fields
    Thanks

    Hi Tara,
    The FM 'DDIF_FIELDINFO_GET' gives you all the fields of the table in the Exporting IT 'DFIES_TAB' that you mention under the parameter 'TABNAME'. I am not sure why it doesnt work for you. Alternatively you can also try this FM 'DDIF_NAMETAB_GET' (This FM is actually used in the FM 'DDIF_FIELDINFO_GET' ) .
    If you are still unsuccesful in meeting your requirement then please paste your piece of code.
    Regards
    Nanda

  • How to list all the rows from the table VBAK

    Friends ,
    How to list all the rows from the table VBAK.select query and the output list is appreciated.

    Hi,
    IF you want to select all the rows for VBAK-
    Write-
    Data:itab type table of VBAK,
           wa like line of itab.
    SELECT * FROM VBAK into table itab.
    Itab is the internal table with type VBAK.
    Loop at itab into wa.
    Write: wa-field1,
    endloop.

  • How can i find the fields for &DOPOS_CPY-WRBT1(I13.0)&

    Hi All,
    In sapscripts, what is the meaning for (13.0)?
    how can i find the fields for &DOPOS_CPY-WRBT1(I13.0)&?
    Thanks.

    meaning for (13.0) is write to form this variable's 13 character non decimal and 0 character decimal places.
    shortly not write decimal places.
    DOPOS_CPY-WRBT1 is exist in form caller program. check in abap program not in sapscript.
    take care
    Çağatay

  • How to list all the notes

    HI,
    Is there some way to report o list all the notes for all account or contacts?
    thanks

    We have similar requirements and we used integration to pull all the notes and then create reports for them from outide of CRMOD.
    Good Luck,
    Thom

  • How to split all the fields of output ls-l from an internal table

    Hi all,
    Using ls-l command i have brought the file attributes of a file like its read and write permissions,creation date ,path etc in a internal table.
    Now how to split all these fields from the internal table or what should be the splitting criteria.
    The field contents of internal table are like this:
    -rw-rw----    1  devadm     sapsys     18360    apr  29......so on
    I want to split this into different fields.
    Kindly suggest.
    Thank You.

    Hi,
    I think the delimiter will be space. For date alone (Apr 29) you need to concatenate after the string has been split.
    Thanks and regards,
    S. Chandramouli

  • How to list all the episodes in a podcast?

    Hi!
    iTunes 7.5.0.20 on Windows XP.
    When subscribing to a podcast, I like to download all the old episodes. Easy enough to do most times (either use GET ALL option or individual GET per episode), but for some of the feeds I subscribe to iTunes doesn't list all the episodes available. Example: if the podcast has 100 episodes, iTunes will only list the last 80 or so. When I look at the same feed using another tool (Google Reader in my case), I see all 100 episodes there.
    What's happening here? How can I get ALL the episodes associated with a feed?
    I searched this forum (almost 300 answered questions) but if the information is there I missed it...
    Thanks!
    Fernando

    Sometimes the episodes are available from the producer directly. Go to the podcast website to check. Sometimes they are listed in an archive area. Sometimes this is a limitation on the producer because of the hosting they use. For popular podcasts it is done to reduce bandwidth. In all but two cases in the past I have been able to get the old episodes from producer. In one of the two cases they admitted the really old files were lost, in the other they said the old files were of such bad quality compared to new ones that they no longer wanted to distribute them.

  • How to identify all the information for a given company code?

    Hi,
    Our company provides data migration services for SAP and other ERP applications. Our customers provide us the specifications for extractions and conversions. We use one or more 3rd party tools to extract data from legacy systems into text/Excel files. Customers use LSMW to load generated files.
    We just got an unusual request. This customer wants to get ALL the data from SAP for a given company code and dump into Excel. They would do some manual editing on the data and load it into a new SAP client.
    In the past, customers would be more specific in their requirements. For example, they will mention Materials, Customers, Inventory, etc. In this case, the customer simply wants ALL the data for a given company code.
    Q1. Is everything in SAP related to company code, either directly or indirectly? For example, can materials be filtered by company code?
    Q2. The tools that we use let us extract data from SAP using SQL-like queries. How do I identify ALL the tables that I would need for a given company code?
    My feeling is the customer themselves are not clear on what they really want. Perhaps they are expecting us to guide them.
    I would appreciate any thoughts that you may have.
    If there is a more appropriate forum for this question, please let me know.
    Thank you in advance for your help.
    Regards,
    Peter

    hi
    t001w is the master table for plants, u can see all plants in this table.
    regads:
    rajesh.k

  • How to List All SAP Messages For my Company

    Currently, I can only see those messages in my Inbox.   How can I see all messages submitted to SAP for ALL of my user's????

    If you are referring to messages posted on SDN then you will now and forever only see your own there is no link to a group.
    If you are referring to the SAP Service Marketplace I believe it's based on your permissions, in my previous life as a Basis Admin I saw all the messages for all the users but many of the developers could only see their own. Not sure how much has changed since 2004 though.

  • How to list all the fonts in an FLA?

    Hello all,
    I want to find a way to list all the fonts in my FLA files. I want to see that the developers get the fonts they need before the problems crop up - wild idea, I know. Using the edit/font mapping option seems to only show fonts which are missing or have been re-mapped. How do I get the FLA to give me the name of every font it's holding?

    Not the answer you want, but the closest you're going to find:
    Open the Movie Explorer (Window/Movie Explorer). Select the "A" button at the top of the panel and deselect all others. This gives you a list of all text in the FLA, with the font listed at the end of each line.

  • How to list all the files in a FTP site?

    I am now using LV7.1 and trying to list all the files (with file name, file size and modified date) on both a local drive and a remote FTP site. I can manage to do on a local drive, but is it possible to list the files on a FTP site?
    Thanks,
    Cola

    Listing files on a local drive and listing the contents of an ftp site are two different things. Access to an ftp site uses a totally different protocol. Off the top of my head, you have a few options:
    Use a third-party tool that can map an ftp drive to a local drive letter. WebDrive is one such client. Note: I'm assuming Windows here.
    Use the Intenet Toolkit.
    Use the LabVIEW TCP/IP functions to write up your own ftp client to connect to the server, change to the desired directory, and send the command to list the contents, which you can parse and spit out as a nice little array of filenames. Check the LabVIEW examples, as I believe there's some examples on this. You should also search this board for "ftp client", as this has been brought up before, and samples have been posted.

  • How to include all the fields of a Table into a Structure.

    How to include a Complete Table into a Structure.
    I want to include all the fields of KNA1 into a structure say W_KNA1(A local structure declared within a program)....How this can b acheived.
    Thanks in Advance.

    if i want to use INCLUDE STRUCTURE.....how will it work.
    TYPES : begin of ty_kna1,
                      INCLUDE STRUCTURE KNA1,
                  end of ty_kna1.
    tell me this is correct stmt.

  • How to retrieve all the tasks for a UserView with the worklist api 10.1.3.1

    Hi,
    I have defined a custom view for user jcooper. The view just displays all the current uncompleted tasks for jcooper.
    I want to use the worklist api to retrieve all the tasks in the view. I first tried it with the following function call:
    taskQueryService.queryViewTasks(workflowContext,viewName, null, null, 0, 0);
    assuming that the viewId in the corresponding java-doc corresponds to the name of the view..However this doesn't work and the method returns a null reference. So viewId is something different than a viewName. Because I cannot find the corresponding viewId for my view (not looked in the db yet, but I don't want to use these ids in my app), I tried the method:
    client.getUserMetadataService().getUserTaskViewList(workflowContext, Partcipant participant);
    However I did not find a method to retrieve a Partipant instance for jcooper in the worklflow api documentation.
    My question now is if someone can help me out to retrieve all the tasks for a specific view. I should be possible I think...
    Thanks!
    Kind regards,
    -Tom

    The second argument (Participant) was added to handle the use case where one user such as an admin or manager needs to retrieve user metadata of another user (offcourse with the required security checks). We will try to do a future enhancement such that if the pariticipant is passed as null then we will assume the metadata is to be retrieved for the workflow context user.
    For now you can define a simple method to create a participant from a workflow context as follows and pass this as an argument to the UserMetadataService call:
    private Participant createParticipant(workflowContext)
    Participant participant = new oracle.bpel.services.workflow.common.model.ObjectFactory().createParticipant();
    participant.setName(workflowContext.getUser();
    participant.setRealm("jazn.com");
    participant.setType("USER");
    return participant;
    // code to retrieve task list...
    UserViewList views = client.getUserMetadataService().getUserTaskViewList(
    workflowContext, createParticipant(workflowContext))
    ...

  • Form Guide: How to hide all the field of a  subform

    Hello,
    I'm an experienced LC Designer user for PDF Forms. I need to work on my first Form guide today.
    The first thing I cannot realize is to hide all the fields in a subform, based on some conditions. Is it possible to make that in a sort of script that work fine for both the pdf and the form guide?
    I have noticed that subform doen't exists into form guide. What append with theire event scripts?
    Thanks
    Denis

    DECLARE
      LC$Block   Varchar2(40) := get_form_property( NAME_IN('System.Current_Form'), FIRST_BLOCK ) ;
    BEGIN
      Loop -- For each block of the form
         Set_Block_Property( LC$Block, INSERT_ALLOWED, PROPERTY_FALSE );
         Set_Block_Property( LC$Block, UPDATE_ALLOWED, PROPERTY_FALSE );
         Set_Block_Property( LC$Block, DELETE_ALLOWED, PROPERTY_FALSE );
         LC$Block := get_block_property( LC$Block, NEXTBLOCK ) ; -- next block
         Exit when LC$Block is null ;
      End loop ;
    END;Francois

  • How to list all the datatypes are being used in the database?

    Is there any way you can list all the oracle datatypes are being used in the database?
    Thanks,
    Chau

    Use USER_TAB_COLUMNS or DBA_TAB_COLUMNS to determing various data type but USER_TAB_COLUMNS will show you what type being used by a schema user

Maybe you are looking for