我首先通过查询交换服务器2003:
POSH>get-wmiobject -class Exchange_mailbox -namespace Root\MicrosoftExchangeV2 -server srv02
获取用户。其中一个可用属性是mailboxguid。所以为了测试,我运行
POSH> get-qaduser -identity <mailboxguid>
然而它不起作用。我需要对mailboxguid做些什么特别的事情吗?
提前致谢
答案 0 :(得分:1)
Get-QADUser尝试通过以下属性之一解析对象:DN,SID,GUID,UPN或Domain \ UserName,mailboxguid不是其中之一。也就是说,您可以使用邮箱“MailboxDisplayName”属性作为Get-QADUser的标识:
get-wmiobject -class Exchange_mailbox -namespace Root \ MicrosoftExchangeV2 -server srv02 | Get-QADUser -identity {$ _。MailboxDisplayName}
编辑:如果您不能使用MailboxDisplayName,请尝试解析LegacyDN WMI属性:
get-wmiobject -class Exchange_mailbox -namespace Root \ MicrosoftExchangeV2 - computerName srv02 | Get-QADUser -identity {$ .LegacyDN.substring($ .LegacyDN.lastIndexOf(“=”)+ 1)}
btw,用-computerName替换-server,Get-WMIObject没有-server参数。 我另外你可以走另一条路而不使用WMI来获取启用邮箱的对象,你可以直接查询AD:
Get-QADObject -sizeLimit 0 -ldap“(homeMDB = *)”
答案 1 :(得分:1)
我认为问题出在其他地方:如果你通过名称从AD获得一个对象(例如用户)并查看ObjectGUID
,它包含一个这样的字符串:
(Get-QADUser -Identity myDomain\myUser).ObjectGUID
-> CAEC64A025153143A6755E0A3DAB5C1A
要通过其GUID获取同一用户,您必须指定:
(Get-QADUser -Identity A064ECCA-1525-4331-A675-5E0A3DAB5C1A).ObjectGUID
-> CAEC64A025153143A6755E0A3DAB5C1A
如果您比较GUID,您会发现它们看起来有些相似但不相同:
CAEC64A0-2515-3143-A675-5E0A3DAB5C1A
A064ECCA-1525-4331-A675-5E0A3DAB5C1A
出现此问题的原因是System.GUID
使用与Active Directory不同的字节顺序来构造GUID。
您可以像这样更正(VB.NET):
Private Shared Function GetCorrectGuid(ByVal aWrongGuid As Guid) As Guid
Dim myGuidString As String = aWrongGuid.ToString("N")
Dim myWrongGuid As Char() = myGuidString.ToCharArray()
Dim myCorrectGuid As Char() = myGuidString.ToCharArray()
myCorrectGuid(0) = myWrongGuid(6)
myCorrectGuid(1) = myWrongGuid(7)
myCorrectGuid(2) = myWrongGuid(4)
myCorrectGuid(3) = myWrongGuid(5)
myCorrectGuid(4) = myWrongGuid(2)
myCorrectGuid(5) = myWrongGuid(3)
myCorrectGuid(6) = myWrongGuid(0)
myCorrectGuid(7) = myWrongGuid(1)
myCorrectGuid(8) = myWrongGuid(10)
myCorrectGuid(9) = myWrongGuid(11)
myCorrectGuid(10) = myWrongGuid(8)
myCorrectGuid(11) = myWrongGuid(9)
myCorrectGuid(12) = myWrongGuid(14)
myCorrectGuid(13) = myWrongGuid(15)
myCorrectGuid(14) = myWrongGuid(12)
myCorrectGuid(15) = myWrongGuid(13)
Return New Guid(New String(myCorrectGuid, 0, 32))
End Function
或者这个(C#):
private static Guid GetCorrectGuid(Guid aWrongGuid) {
string myGuidString = aWrongGuid.ToString("N");
char[] myWrongGuid = myGuidString.ToCharArray();
char[] myCorrectGuid = myGuidString.ToCharArray();
myCorrectGuid[0] = myWrongGuid[6];
myCorrectGuid[1] = myWrongGuid[7];
myCorrectGuid[2] = myWrongGuid[4];
myCorrectGuid[3] = myWrongGuid[5];
myCorrectGuid[4] = myWrongGuid[2];
myCorrectGuid[5] = myWrongGuid[3];
myCorrectGuid[6] = myWrongGuid[0];
myCorrectGuid[7] = myWrongGuid[1];
myCorrectGuid[8] = myWrongGuid[10];
myCorrectGuid[9] = myWrongGuid[11];
myCorrectGuid[10] = myWrongGuid[8];
myCorrectGuid[11] = myWrongGuid[9];
myCorrectGuid[12] = myWrongGuid[14];
myCorrectGuid[13] = myWrongGuid[15];
myCorrectGuid[14] = myWrongGuid[12];
myCorrectGuid[15] = myWrongGuid[13];
return new Guid(new string(myCorrectGuid, 0, 32));
}
是的,我知道这不是最有效的方法,但我根本没有时间将它重写为基于字节数组并使用arraycopy的函数。遗憾。
希望有所帮助 CHHA