Solved

Looking for a script to set Delivery Restrictions to multiple groups

Posted on 2010-08-19
3
538 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

Free book by J.Peter Bruzzese, Microsoft MVP

Are you using Office 365? Trying to set up email signatures but you’re struggling with transport rules and connectors? Let renowned Microsoft MVP J.Peter Bruzzese show you how in this exclusive e-book on Office 365 email signatures. Better yet, it’s free!

Join & Write a Comment

Resolve DNS query failed errors for Exchange
ADCs have gained traction within the last decade, largely due to increased demand for legacy load balancing appliances to handle more advanced application delivery requirements and improve application performance.
In this video we show how to create a Shared Mailbox 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 >> Sha…
The basic steps you have just learned will be implemented in this video. The basic steps are shown to configure an Exchange DAG in a live working Exchange Server Environment and manage the same (Exchange Server 2010 Software is used in a Windows Ser…

707 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now