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:
Quote:
@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.
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.
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 "