Solved

Looking for a script to set Delivery Restrictions to multiple groups

Posted on 2010-08-19
3
542 Views
Last Modified: 2012-05-10
Hello,
i've come upon a request to have a mechnisem that will read a username from an input box and will add that user name to the Allowed Senders under the Messege Delivery Restrictions tab in Exchange 2007 of groups listed in a text file.
I think the value in adsi is "authOrig"?
is there any tool or script for this?
0
Comment
Question by:johnnyjonathan
  • 2
3 Comments
 
LVL 2

Expert Comment

by:misterlupo
ID: 33483080
Do you have the Distinguished Names of your groups? If so, you could use the below script. If you want to modify too many I can modify the script to take an external file with group DNs

P.S.:
If you don't have it already, you need admod and adfind from Joe Richards
http://www.joeware.net/freetools/tools/adfind/index.htm
http://www.joeware.net/freetools/tools/admod/index.htm


@echo off
setlocal
set usrname=
set usrdn=
set /p usrname=Please enter the user name: 
if "%usrname%"=="" echo ERROR: No user name was provided. && goto :eof
for /f "tokens=*" %%a in ('adfind -default -f "&(objectclass=user)(objectcategory=person)(samaccountname=%usrname%)" -list distinguishedname') do set usrdn=%%a
if "%usrdn%"=="" echo ERROR: User name "%usrname%" cannot be resolved to a DN. && goto :eof
echo Resolving "%usrname%" to "%usrdn%"

admod -b "Your Group DN 1" "authOrig:+:%usrdn%"
admod -b "Your Group DN 2" "authOrig:+:%usrdn%"
admod -b "Your Group DN 3" "authOrig:+:%usrdn%"
admod -b "Your Group DN 4" "authOrig:+:%usrdn%"

Open in new window

0
 

Author Comment

by:johnnyjonathan
ID: 33495085
Hi,

No, I only have the display name and not the full DN. And they are groups that divided between several different OU's
0
 
LVL 2

Accepted Solution

by:
misterlupo earned 500 total points
ID: 33509802
I assume you have the display name in a file. Unfortunally display name is not unique in the AD i.e. you can have two or more objects with the same display name. However the below script will search for objects with the given display name and doing the modification. It won't do anything if more than one group matches the given diplay name.

Before using it, please set the displaynamefile variable in the third line to the file that contains the display names.


@echo off
setlocal
set displaynamefile=
set usrname=
set usrdn=
set /p usrname=Please enter the user name: 
if "%usrname%"=="" echo ERROR: No user name was provided. && goto :eof
for /f "tokens=*" %%a in ('adfind -default -f "&(objectclass=user)(objectcategory=person)(samaccountname=%usrname%)" -list distinguishedname') do set usrdn=%%a
if "%usrdn%"=="" echo ERROR: User name "%usrname%" cannot be resolved to a DN. && goto :eof
echo Resolving "%usrname%" to "%usrdn%"

for /f "usebackq tokens=*" %%a in ("%displaynamefile%") do adfind -default -f "&(objectclass=group)(objectcategory=group)(displayname=%%a)" -dsq | admod -safety 1 "authOrig:+:%usrdn%"

Open in new window

0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Follow this checklist to learn more about the 15 things you should never include in an email signature from personal quotes, animated gifs and out-of-date marketing content.
This article explains how to install and use the NTBackup utility that comes with Windows Server.
In this video we show how to create a Contact in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.: First we need to log into the Exchange Admin Center. Navigate to the Recipients >> Contact ta…
In this video we show how to create an Address List in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.: First we need to log into the Exchange Admin Center. Navigate to the Organization >> Ad…

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question