Results 1 to 3 of 3

Thread: DSMOD from batch and text file

  1. #1
    Join Date
    Oct 2005
    Posts
    20

    DSMOD from batch and text file

    Hi,

    I’m running a server with few clients PCs. I want to restrict users using Text file on their PCs. Hence I created a Batch file which is as follow:

    @echo off
    if {%1}=={} @echo Syntax: disableDNs FileName&goto :EOF
    if not exist %1 @echo Syntax: disableDNs %1 not found.&goto :EOF
    setlocal ENABLEDELAYEDEXPANSION
    set file=%1
    @echo.
    for /f "Tokens=*" %%u in ('type %file%') do (
    set user=%%u
    set user="!user:"=!"
    @echo DSMOD USER !user! -desc Disabled -disabled yes
    DSMOD USER !user! -desc Disabled -disabled yes
    @echo.
    )
    endlocal

    --text file--

    "CN=Lastname,CN=Firstname,CN=Users,DC=test,DC=com"
    "CN=Madeup,CN=Name,OU=Test,DC=test,DC=com"

    etc
    It should restrict the users but don’t know why it gets failed. This is the error message I received while running the same:

    “dsmod failed:CN=Lastname,CN=Firstname,CN=Users,DC=test,DC=com\ :A referral was sent from the server.”


    Any idea how can I make it work? Please help.

  2. #2
    Join Date
    Aug 2005
    Posts
    257

    Re: DSMOD from batch and text file

    Most probable cause for the said error could be the Distinguished Name (DN). TO me DN for the user looks incorrect. If I consider as the user object is in the "cn=User" container (and not in an OU), and the Common Name of the user is "Lastname, Firstname", then the DN should be something like this:

    cn=Lastname\, Firstname,cn=Users,dc=Test,dc=com

    Just try it out and see if it works.

  3. #3
    Join Date
    Oct 2005
    Posts
    20

    RE: DSMOD from batch and text file

    Thanks for your reply MANIK. But before reading your post, I managed to fix it somehow. I made some changes but I don’t know how it fixed the problem hence I need to know what actually happened. See I made the following change in the script. I just removed the following line: set user="!user:"=!"

    If I’m not wrong it was designed to put the name in quotes, Because my text file already had them in quotes, it was removing the last quote, putting a space in, and then putting down it's own quote. So instead of DSMOD USER

    "CN=Lastname,CN=Firstname,CN=Users,DC=test,DC=com"
    it became DSMOD USER "CN=Lastname,CN=Firstname,CN=Users,DC=test,DC=com "

Similar Threads

  1. Editing text file using a batch file
    By beelow in forum Software Development
    Replies: 8
    Last Post: 09-03-2010, 12:27 AM
  2. Replace text string using batch file
    By jean-paul martell in forum Operating Systems
    Replies: 2
    Last Post: 23-06-2009, 01:18 PM
  3. Batch Script Text file parse
    By tator.usenet@gmail.com in forum Windows Server Help
    Replies: 5
    Last Post: 25-03-2009, 02:12 AM
  4. Batch Script to parse lines in text file
    By jntoner1@gmail.com in forum Windows Server Help
    Replies: 8
    Last Post: 28-01-2009, 04:38 AM
  5. scheduled printing of a text file using batch files or schtasks
    By Gadgetman in forum Windows XP Support
    Replies: 10
    Last Post: 12-06-2008, 11:48 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,711,639,546.67172 seconds with 17 queries