Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Looking for a script to set Delivery Restrictions to multiple groups

Posted on 2010-08-19
3
Medium Priority
?
554 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 2000 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

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

Question has a verified solution.

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

Steps to fix “Unable to mount database. (hr=0x80004005, ec=1108)”.
Exchange database can often fail to mount thereby halting the work of all users connected to it. Finding out why database isn’t mounting is crucial and getting the server back online. Stellar Phoenix Mailbox Exchange Recovery is a champion product t…
In this video we show how to create an email address policy 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 Mail Flow…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Suggested Courses

581 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