Solved

Looking for a script to set Delivery Restrictions to multiple groups

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Lotus Notes – formerly IBM Notes – is an email client application, while IBM Domino (earlier Lotus Domino) is an email server. The client possesses a set of features that are even more advanced as compared to that of Outlook. Likewise, IBM Domino is…
Utilizing an array to gracefully append to a list of EmailAddresses
In this video we show how to create a Distribution Group 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 >>…
In this video we show how to create an Accepted Domain 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 >> Ac…

914 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

20 Experts available now in Live!

Get 1:1 Help Now