您的位置:首页 > 其它

Exchange2007用户-用户全部访问权限授权命令及验证脚本

2011-11-08 14:36 507 查看
在Exchange2007中,如果想让某个用户(通常是管理员)可以有全部权限去访问另一个用户的邮箱数据,可以用以下命令:

Add-MailboxPermission pinlv -User admin -AccessRights FullAccess

以上命令可以让用户admin可以有pinlv用户的全部访问权限,验证方法如下:

1、以WebDAV的方式访问:

function GetUnReadMail() {

data = "<?xml version='1.0'?>" +
"<a:propfind xmlns:a='DAV:'>" +
"<a:prop xmlns:uid='urn:schemas:calendar:'>" +
"<a:contentclass></a:contentclass>" +
'</a:prop>' +
"</a:propfind>";

_xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
_xmlHttp.open("PROPFIND", 'http://mail.shrcoa.gov.cn/exchange/taizhan', false, "admin@shrcoa.gov.cn", "P@$$w0rd1");
_xmlHttp.onreadystatechange = GetUnReadMail_Completed;
_xmlHttp.setRequestHeader("Content-Type","text/xml");
_xmlHttp.send(data);
}

function GetUnReadMail_Completed() {
if (_xmlHttp.readyState == "4") {
if (_xmlHttp.status == "200") {
var content = _xmlHttp.responseText;
alert(content);
document.getElementById('txtx').innerText = content;
} else {
alert('status:' + _xmlHttp.status + ';responseText:' + _xmlHttp.responseText);
}
}
}

返回结果如下,类似如下的长串xml就是正确的:

---------------------------
Microsoft Internet Explorer
---------------------------
status:207;responseText:<?xml version="1.0"?><a:multistatus xmlns:b="urn:uuid:c2f41010-65b3-11d1-a29f-00aa00c14882/" xmlns:c="xml:" xmlns:a="DAV:"><a:response><a:href>http://mail.shrcoa.gov.cn/exchange/taizhan/</a:href><a:propstat><a:status>HTTP/1.1 200 OK</a:status><a:prop><a:contentclass>urn:content-classes:folder</a:contentclass></a:prop></a:propstat></a:response><a:response><a:href>http://mail.shrcoa.gov.cn/exchange/taizhan/%E6%94%B6%E4%BB%B6%E7%AE%B1/Planning%20Meeting-3.EML</a:href><a:propstat><a:status>HTTP/1.1 200 OK</a:status><a:prop><a:contentclass>urn:content-classes:calendarmessage</a:contentclass></a:prop></a:propstat></a:response><a:response><a:href>http://mail.shrcoa.gov.cn/exchange/taizhan/%E6%97%A5%E5%8E%86/Planning%20Meeting-3.EML</a:href><a:propstat><a:status>HTTP/1.1 200 OK</a:status><a:prop><a:contentclass>urn:content-classes:appointment</a:contentclass></a:prop></a:propstat></a:response><a:response><a:href>http://mail.shrcoa.gov.cn/exchange/taizhan/%E6%94%B6%E4%BB%B6%E7%AE%B1/Planning%20Meeting-2.EML</a:href><a:propstat><a:status>HTTP/1.1 200 OK</a:status><a:prop><a:contentclass>urn:content-classes:calendarmessage</a:contentclass></a:prop></a:propstat></a:response><a:response><a:href>http://mail.shrcoa.gov.cn/exchange/taizhan/%E6%97%A5%E5%8E%86/Planning%20Meeting-2.EML</a:href><a:propstat><a:status>HTTP/1.1 200 OK</a:status><a:prop><a:contentclass>urn:content-classes:appointment</a:contentclass></a:prop></a:propstat></a:response><a:response><a:href>http://mail.shrcoa.gov.cn/exchange/taizhan/%E6%94%B6%E4%BB%B6%E7%AE%B1/Planning%20Meeting.EML</a:href><a:propstat><a:status>HTTP/1.1 200 OK</a:status><a:prop><a:contentclass>urn:content-classes:calendarmessage</a:contentclass></a:prop></a:propstat></a:response><a:response><a:href>http://mail.shrcoa.gov.cn/exchange/taizhan/%E6%97%A5%E5%8E%86/Planning%20Meeting.EML</a:href><a:propstat><a:status>HTTP/1.1 200 OK</a:status><a:prop><a:contentclass>urn:content-classes:appointment</a:contentclass></a:prop></a:propstat></a:response><a:response><a:href>http://mail.shrcoa.gov.cn/exchange/taizhan/%E6%94%B6%E4%BB%B6%E7%AE%B1/%E9%80%81%E6%9D%A5%E6%A3%80%E6%B5%8B%E7%9A%84%E7%8C%AA%E8%80%B3%E6%9C%B5%E6%98%AF%E5%81%87%E7%9A%84.EML</a:href><a:propstat><a:status>HTTP/1.1 200 OK</a:status><a:prop><a:contentclass>urn:content-classes:message</a:contentclass></a:prop></a:propstat></a:response><a:response><a:href>http://mail.shrcoa.gov.cn/exchange/taizhan/%E5%B7%B2%E5%8F%91%E9%80%81%E9%82%AE%E4%BB%B6/%E9%80%81%E6%9D%A5%E6%A3%80%E6%B5%8B%E7%9A%84%E7%8C%AA%E8%80%B3%E6%9C%B5%E6%98%AF%E5%81%87%E7%9A%84.EML</a:href><a:propstat><a:status>HTTP/1.1 200 OK</a:status><a:prop><a:contentclass>urn:content-classes:message</a:contentclass></a:prop></a:propstat></a:response><a:response><a:href>http://mail.shrcoa.gov.cn/exchange/taizhan/%E6%94%B6%E4%BB%B6%E7%AE%B1/%E4%B8%BA%E5%95%8A%E7%9C%8B%E5%88%B0%E7%9C%8B%E5%A4%84%E5%A5%B3%E5%A4%84%E5%A5%B3%E4%BD%A0.EML</a:href><a:propstat><a:status>HTTP/1.1 200 OK</a:status><a:prop><a:contentclass>urn:content-classes:message</a:contentclass></a:prop></a:propstat></a:response><a:response><a:href>http://mail.shrcoa.gov.cn/exchange/taizhan/%E5%B7%B2%E5%8F%91%E9%80%81%E9%82%AE%E4%BB%B6/%E4%B8%BA%E5%95%8A%E7%9C%8B%E5%88%B0%E7%9C%8B%E5%A4%84%E5%A5%B3%E5%A4%84%E5%A5%B3%E4%BD%A0.EML</a:href><a:propstat><a:status>HTTP/1.1 200 OK</a:status><a:prop><a:contentclass>urn:content-classes:message</a:contentclass></a:prop></a:propstat></a:response><a:response><a:href>http://mail.shrcoa.gov.cn/exchange/taizhan/%E8%8D%89%E7%A8%BF/%E7%AD%94%E5%A4%8D:%20%E7%A7%BB%E5%8A%A8%E5%8A%9E%E5%85%AC%E7%99%BB%E5%BD%95%E7%95%8C%E9%9D%A2%E5%8F%AF%E4%BB%A5%E4%BA%86.EML</a:href><a:propstat><a:status>HTTP/1.1 200 OK</a:status><a:prop><a:contentclass>urn:content-classes:message</a:contentclass></a:prop></a:propstat></a:response><a:response><a:href>http://mail.shrcoa.gov.cn/exchange/taizhan/%E5%B7%B2%E5%8F%91%E9%80%81%E9%82%AE%E4%BB%B6/%E9%A3%8E%E8%8E%B7%E8%81%8A%E5%A4%A9.EML</a:href><a:propstat><a:status>HTTP/1.1 200 OK</a:status><a:prop><a:contentclass>urn:content-classes:message</a:contentclass></a:prop></a:propstat></a:response><a:response><a:href>http://mail.shrcoa.gov.cn/exchange/taizhan/%E6%94%B6%E4%BB%B6%E7%AE%B1/Re:%20%E7%A7%BB%E5%8A%A8%E5%8A%9E%E5%85%AC%E7%99%BB%E5%BD%95%E7%95%8C%E9%9D%A2%E5%8F%AF%E4%BB%A5%E4%BA%86-2.EML</a:href><a:propstat><a:status>HTTP/1.1 200 OK</a:status><a:prop><a:contentclass>urn:content-classes:message</a:contentclass></a:prop></a:propstat></a:response><a:response><a:href>http://mail.shrcoa.gov.cn/exchange/taizhan/%E6%94%B6%E4%BB%B6%E7%AE%B1/%E7%A7%BB%E5%8A%A8%E5%8A%9E%E5%85%AC%E7%99%BB%E5%BD%95%E7%95%8C%E9%9D%A2%E5%8F%AF%E4%BB%A5%E4%BA%86.EML</a:href><a:propstat><a:status>HTTP/1.1 200 OK</a:status><a:prop><a:contentclass>urn:content-classes:message</a:contentclass></a:prop></a:propstat></a:response><a:response><a:href>http://mail.shrcoa.gov.cn/exchange/taizhan/%E6%94%B6%E4%BB%B6%E7%AE%B1/%E5%BE%90%E6%B5%A9%E4%BD%A0%E5%A5%BD.EML</a:href><a:propstat><a:status>HTTP/1.1 200 OK</a:status><a:prop><a:contentclass>urn:content-classes:message</a:contentclass></a:prop></a:propstat></a:response><a:response><a:href>http://mail.shrcoa.gov.cn/exchange/taizhan/%E6%94%B6%E4%BB%B6%E7%AE%B1/%E9%85%8D%E7%BD%AE%E7%A7%BB%E5%8A%A8%E5%8A%9E%E5%85%AC.EML</a:href><a:propstat><a:status>HTTP/1.1 200 OK</a:status><a:prop><a:contentclass>urn:content-classes:message</a:contentclass></a:prop></a:propstat></a:response><a:response><a:href>http://mail.shrcoa.gov.cn/exchange/taizhan/%E6%94%B6%E4%BB%B6%E7%AE%B1/%E8%AF%B7%E6%B5%8B%E8%AF%95%E7%A7%BB%E5%8A%A8%E5%8A%9E%E5%85%AC.EML</a:href><a:propstat><a:status>HTTP/1.1 200 OK</a:status><a:prop><a:contentclass>urn:content-classes:message</a:contentclass></a:prop></a:propstat></a:response><a:response><a:href>http://mail.shrcoa.gov.cn/exchange/taizhan/%E5%B7%B2%E5%8F%91%E9%80%81%E9%82%AE%E4%BB%B6/%E8%AF%B7%E6%B5%8B%E8%AF%95%E7%A7%BB%E5%8A%A8%E5%8A%9E%E5%85%AC.EML</a:href><a:propstat><a:status>HTTP/1.1 200 OK</a:status><a:prop><a:contentclass>urn:content-classes:message</a:contentclass></a:prop></a:propstat></a:response><a:response><a:href>http://mail.shrcoa.g
---------------------------
确定
---------------------------

--============================================================================

2、以webservice的方式访问,代码如下,使用帐号admin创建一个日程,参与人是taizhan、jc:

function AddCalendar() {
data = '<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' +
'xmlns:xsd="http://www.w3.org/2001/XMLSchema" ' +
'xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" ' +
'xmlns:t="'" target=_blank>http://schemas.microsoft.com/exchange/services/2006/types">' +
'<soap:Body>' +
'<CreateItem xmlns="http://schemas.microsoft.com/exchange/services/2006/messages" ' +
'xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types" ' +
'SendMeetingInvitations="SendToAllAndSaveCopy" > ' +
'<SavedItemFolderId>' +
'<t:DistinguishedFolderId Id="calendar"/>' +
'</SavedItemFolderId>' +
'<Items>' +
'<t:CalendarItem xmlns="'" target=_blank>http://schemas.microsoft.com/exchange/services/2006/types">' +
'<Subject>Planning Meeting</Subject>' +
'<Body BodyType="Text">Plan the agenda for next weeks meeting.</Body>' +
'<ReminderIsSet>true</ReminderIsSet>' +
'<ReminderMinutesBeforeStart>60</ReminderMinutesBeforeStart>' +
'<Start>2011-11-07T14:00:00</Start>' +
'<End>2011-11-07T15:00:00</End>' +
'<IsAllDayEvent>false</IsAllDayEvent>' +
'<LegacyFreeBusyStatus>Busy</LegacyFreeBusyStatus>' +
'<Location>Conference Room 721</Location>' +
'<RequiredAttendees>' +
'<Attendee>' +
'<Mailbox>' +
'<EmailAddress>taizhan@shrcoa.gov.cn</EmailAddress>' +
'</Mailbox>' +
'</Attendee>' +
'<Attendee>' +
'<Mailbox>' +
'<EmailAddress>jc@shrcoa.gov.cn</EmailAddress>' +
'</Mailbox>' +
'</Attendee>' +
'</RequiredAttendees>' +
'</t:CalendarItem>' +
'</Items>' +
'</CreateItem>' +
'</soap:Body>' +
'</soap:Envelope>';

_xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
_xmlHttp.open("POST", 'http://mail.shrcoa.gov.cn/ews/exchange.asmx', false, "admin@shrcoa.gov.cn", "P@$$w0rd1");
_xmlHttp.onreadystatechange = AddCalendar_Completed;
_xmlHttp.setRequestHeader("Content-Type","text/xml");
_xmlHttp.send(data);
}

function AddCalendar_Completed() {
if (_xmlHttp.readyState == "4") {
if (_xmlHttp.status == "200") {
var content = _xmlHttp.responseText;
alert(content);
document.getElementById('txtx').innerText = content;
} else {
alert('status:' + _xmlHttp.status + ';responseText:' + _xmlHttp.responseText);
}
}
}

返回结果如下,<m:ResponseCode>NoError</m:ResponseCode>表示操作成功,可以登录到owa去看看日程是创建成功了的

---------------------------
Microsoft Internet Explorer
---------------------------
<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Header><t:ServerVersionInfo MajorVersion="8" MinorVersion="0" MajorBuildNumber="685" MinorBuildNumber="24" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types" /></soap:Header><soap:Body><m:CreateItemResponse xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages"><m:ResponseMessages><m:CreateItemResponseMessage ResponseClass="Success"><m:ResponseCode>NoError</m:ResponseCode><m:Items><t:CalendarItem><t:ItemId Id="AAATAGFkbWluQHNocmNvYS5nb3YuY24ARgAAAAAAGBisSW/waUelfFrDJLrx4AcAfKnRtXWH00C8SFYAbnghHgAEDT7DXQAAfKnRtXWH00C8SFYAbnghHgA697j3cgAA" ChangeKey="DwAAABYAAAB8qdG1dYfTQLxIVgBueCEeADr3uU4Q" /></t:CalendarItem></m:Items></m:CreateItemResponseMessage></m:ResponseMessages></m:CreateItemResponse></soap:Body></soap:Envelope>
---------------------------
确定
---------------------------
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐