我目前正在开展一个通过 Web 界面创建分发列表的项目。我选择使用 PHP 来完成这个项目,因为我对它非常熟悉。
我知道如何在 PHP 中添加 LDAP 帐户,但我的问题是,我不确定需要哪些 AD 属性才能将组转换为分发列表。我知道我可以使用 powershell,但我更愿意以我熟悉的方式执行此操作。
我用来编译分发列表属性的代码如下:
$attDist = array(
"managedBy" => $secGroupDn,
"groupType" => "8", // This number denotes a universal distribution group
"cn" => $dlName,
"samaccountname" => $dlName,
"displayname" => $dlName,
"objectClass" => "Group",
"legacyexchangeDN" => "/o=First Organization/ou=Exchange Administrative Group (FYDIBOHF23SPDLT)/cn=Recipients/cn=". substr($dlName, 0, 4) . time(),
"proxyaddresses" => array("SMTP:". $dlName ."@testdomain.local"),
"showinaddressbook" => array(
"CN=Groups(VLV),CN=All System Address Lists,CN=Address Lists Container,CN=First Organization,CN=Microsoft Exchange,CN=Services,CN=Configuration,DC=testdomain,DC=local",
"CN=All Groups(VLV),CN=All System Address Lists,CN=Address Lists Container,CN=First Organization,CN=Microsoft Exchange,CN=Services,CN=Configuration,DC=testdomain,DC=local",
"CN=All Recipients(VLV),CN=All System Address Lists,CN=Address Lists Container,CN=First Organization,CN=Microsoft Exchange,CN=Services,CN=Configuration,DC=testdomain,DC=local",
"CN=Default Global Address List,CN=All Global Address Lists,CN=Address Lists Container,CN=First Organization,CN=Microsoft Exchange,CN=Services,CN=Configuration,DC=testdomain,DC=local",
"CN=All Groups,CN=All Address Lists,CN=Address Lists Container,CN=First Organization,CN=Microsoft Exchange,CN=Services,CN=Configuration,DC=testdomain,DC=local",
),
"mail" => $dlName . "@testdomain.local",
"msexchversion" => "44220983382016",
"msexcharbitrationmailbox" => "CN=SystemMailbox{1f05a927-ccef-4207-91c0-7550cb8790db},CN=Users,DC=testdomain,DC=local",
"msexchrequireauthtosendto" => "TRUE",
"mailnickname" => $dlName,
"msexchpoliciesincluded" => array(
"bcdf8b57-a774-4d82-980a-68f7f7d9f54d",
"{26491cfc-9e50-4857-861b-0cb8df22b5d7}",
),
"msexchrecipientdisplaytype" => "1",
"description" => "Managed by: Someone",
"info" => "Created by ". $creatorName ." on ". date("d/M/Y") .". CA ". $caTicket .". Managed by: TBD",
(英文):
答案1
我无法用 PHP 具体解决这个问题,但我可以告诉你,我通过 perl 使用以下调用使用 LDAP 创建了通用邮件启用安全组/DL:
$res = $ldap->add(
dn => $dn,
attr => [
sAMAccountName => $group,
name => $group,
displayName => $dname,
displayNamePrintable => $pdname,
objectclass => [ 'top', 'group' ],
groupType => -2147483640
]
);
然后,您需要添加“mail”、“mailNickname”、“proxyAddresses”的属性,并且根据您的环境,您可能需要填充“legacyExchangeDN”。
答案2
为什么不使用正确的 API?Exchange Web Services (EWS) 有详尽的文档,应该可以支持您想要执行的任何操作。