Re: Domain information through vbs

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Richard,

Sadly we do not have/use Active Directory so I am stuck using dos (for now
at least). Could you help me some more please.

Thanks,

Daniel

"Richard Mueller [MVP]" wrote:

> Daniel wrote:
>
> > Here is what I would like to achieve but do not know how!
> >
> > I would like to create a script that
> >
> > 1- run dos command "net group GROUPNAME /domain" and write it to a
> textfile
> > 2- Using the textfile of users, run the dos command "net user USERNAME
> > /domain" (using 1 by 1 the user from the textfile in 1) and write it to
> > another textfile
> > 3- Go through the textfile created in 2 and validate certain parameter
> such
> > as "logon script".
> >
> > Can someone run me through this or point me to a web site that can provide
> > me with the basics on how I can do this type of script.
> >
> > One of my main problem is how I can use the text file created in 1 in 2
> > since it is output in a tabular format (3 columns) and vbs will read it 1
> > line at a time. How can I transform the dos output into a valid format to
> > use in 2?
>
> Hi,
>
> A problem I see is the header information output by these commands. The
> script would have to parse through this to find the member names, then parse
> for logon script. Also, you would have a separate output file for each
> member. This can be done using the FileSystemObject. You would use the Run
> method of the wshShell object to run the DOS commands and redirect the
> output to a file, then use the FileSystemObject to read the file. However,
> it would be much easier to read the information directly from Active
> Directory using ADSI. For example:
>
> ' Specify the group Distinguished Name.
> strGroup = "cn=MyGroup,ou=Sales,dc=MyDomain,dc=com"
>
> ' Bind to the group object in Active Directory.
> Set objGroup = GetObject("LDAP://"; & strGroup)
>
> ' Enumerate direct members of the group.
> For Each objMember In objGroup.Members
> ' Only consider members that are users (skip groups).
> If (objMember.Class = "user") Then
> ' Output user NT name and logon script.
> Wscript.Echo objMember.sAMAccountName & ", " & objMember.scriptPath
> End If
> Next
>
> This VBScript program could be run at a command prompt, with the output
> redirected to a text file. If you really need to use the DOS commands and
> intermediate files, reply. Otherwise, for documentation on other attributes
> available for user objects (like scriptPath and sAMAccountName), see this
> link:
>
> http://www.rlmueller.net/UserAttributes.htm
>
> The first spreadsheet documents the attributes corresponding to the fields
> in the Properties dialog for users in ADUC.
>
> --
> Richard
> Microsoft MVP Scripting and ADSI
> Hilltop Lab web site - http://www.rlmueller.net
> --
>
>
>
.



Relevant Pages

  • Queue for AD Group member and members class
    ... I was wrote a script used to collect all groups and groups member' name & ... spreadsheet, ... 'Bind to Active Directory ...
    (microsoft.public.windows.server.scripting)
  • member to group
    ... I have need to extract the list of member to a group in Active Directory. ... Do you have a script for this question. ...
    (microsoft.public.windows.server.scripting)
  • Re: Re[4]: DoS vulnerabilities in Firefox, Internet Explorer, Chrome, Opera and other browsers
    ... I was carried away because the author used scripts in the PoC of the issue in question which made unconditional recursion possible. ... Hence it doesn't affect or DoS the latest browsers. ... I more than agree that an issue to be classified as a security vulnerability if a combination of tags/properties/scripts causes or is capable of causing malice in any form while conforming to the standards. ... If the issue noted in this context DoS by a form of unconditional recursion to create 'out of memory' or stack overflow sortof situation but requires a task kill operation on the script engine's host (the browser in this context). ...
    (Bugtraq)
  • Re: DOS Printing from Windows Server 2003 TS?
    ... STAT-NT03 is the TS server name. ... We will see if it works for the 5 remote users over the Internet. ... We have a customer who is still using and old DOS version of software ... could not find anything except a Kixstart script. ...
    (microsoft.public.windows.terminal_services)
  • Re: Need assistance badly!
    ... I have tried cobbling together a script that does this, ... I would use ADO in a VBScript program to retrieve all users with the ... Dim objRootDSE, strDNSDomain, strQuery, adoRecordset, strName, strCN ... adoConnection.Open "Active Directory Provider" ...
    (microsoft.public.scripting.vbscript)