Thank you again Steven.
You are a genius
On Nov 18, 2010, at 4:39 PM, "Steven Manross" <[email protected]> wrote:
> So.. that email address is not Exchange enabled at this point. You
> just set the email address property. This makes the group Exchange
> mail-enabled, and you can now send email to that group, and providing it
> has memebers that are mail or mailbox enabled, they will get the mail.
>
> use Win32::OLE;
>
> $GLOBALGROUP = 2;
> $DOMAINLOCALGROUP = 4;
> $UNIVERSALGROUP = 8;
> $SECURITYGROUP = 2147483648;
> $ADS_PROPERTY_APPEND = 3;
>
> $ou=Win32::OLE->GetObject("LDAP://OU=Test,DC=somedomain,DC=com");
> $group=$ou->Create("Group","cn=GroupCA");
> $group->Put("samAccountName","GroupCA");
> $group->Put("groupType",($UNIVERSALGROUP | $SECURITYGROUP));
> $group->SetInfo;
> if (Win32::OLE->LastError() != 0) {
> print "Error in 1st SetInfo: " . Win32::OLE->LastError()."\n";
> }
> $group->MailEnable;
> if (Win32::OLE->LastError() != 0) {
> print "Error in MailEnable: " . Win32::OLE->LastError()."\n";
> }
> $group->Put("proxyAddresses", "SMTP:[email protected]");
> $group->Put("mail","[email protected]");
> $group->SetInfo();
> if (Win32::OLE->LastError() != 0) {
> print "Error in 2nd SetInfo: " . Win32::OLE->LastError()."\n";
> }
> $group->PutEx($ADS_PROPERTY_APPEND,
> "member",
> ['CN=some user,OU=some ou,DC=somedomain,DC=com']);
> $group->SetInfo;
> if (Win32::OLE->LastError() != 0) {
> print "Error in 3rd SetInfo: " . Win32::OLE->LastError()."\n";
> }
>
> Steven
> ________________________________
>
> From: [email protected]
> [mailto:[email protected]] On Behalf Of
> A F
> Sent: Thursday, November 18, 2010 3:56 PM
> To: [email protected]
> Subject: Problem creatign group with email address using
> Win32::OLE
>
>
> Thanks Steven for your help in my code. Now I can create a group
> in AD but it doesn't create an exchange email. After running the script
> and when I go to AD I can see the email is specified at the Email field
> but trying to send an email to it , I get a bouce back even though I
> have members in the group.
>
>
> use strict;
> use warnings;
> use Win32::OLE;
> my $GLOBALGROUP = 2;
> my $DOMAINLOCALGROUP = 4;
> my $UNIVERSALGROUP = 8;
> my $SECURITYGROUP = 2147483648;
> my $ADS_PROPERTY_APPEND = 3;
>
> my $ou=Win32::OLE->GetObject(LDAP://OU=some
> ou,DC=somedomain,DC=com <ldap://OU=some ou,DC=somedomain,DC=com> );
> my $group=$ou->Create("Group","cn=GroupCA");
> $group->put("samAccountName","GroupCA");
> $group->put("groupType",($UNIVERSALGROUP | $SECURITYGROUP));
> $group->put("mail","[email protected]");
> $group->SetInfo;
> $group->PutEx($ADS_PROPERTY_APPEND,
> "member",
> ['CN=last\\,
> first,CN=Users,DCDC=somedomain,DC=com']);
> $group->SetInfo;
> if (Win32::OLE->LastError() != 0 )
> {
> print "Some Error: ". Win32::OLE->LastError() ."\n";
> exit 0;
> }
>
>
_______________________________________________
Perl-Win32-Admin mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs