Candi Suriano
2007-10-04 21:25:03 UTC
I'm creating a user in Active Directory, setting the mail nickname and then
trying to mail enable them. This code has worked for 18 months with very few
problems. Now there's a new twist. I have to create the user and mailbox in a
different domain than the one I'm running in. I impersonate a domain admin
in the domain. Everything works up to the point where it tries to create the
mailbox. Then I get a "Catastrophic failure" 0x8000FFFF error message. Does
anyone have any idea what could be wrong?
I've appended a sample of the code to the end of this message. All of the
LDAP strings have been checked by multiple pairs of eyes. They specify valid
containers in AD and valid stores in Exchange. And I've left out some
details such as exception handling and the code for impersonation for the
sake of brevity.
--
Candi
Private Sub Create()
Dim newIdentity As System.Security.Principal.WindowsIdentity = Nothing
Dim newContext As
System.Security.Principal.WindowsImpersonationContext = Nothing
newIdentity = GetWindowsIdentity(GetValueFromConfig("CECUser1"),
"CEC", GetValueFromConfigEncrypt("CECPassword1"))
newContext = newIdentity.Impersonate
CreateUser()
newContext.Undo
End Sub
Private Sub CreateUser
Dim entry As DirectoryEntry = Nothing
Dim user As DirectoryEntry = Nothing
Dim strPath As String = String.Empty
Dim strExchangePath As String = String.Empty
Dim Mailbox As CDOEXM.IMailboxStore
Dim username As String = "testUser"
strPath =
String.Format("LDAP://{0}/OU={1},OU={2},OU={3},OU={4},OU={5},{6}", dcName,
"Users", "OEG Staff", "Hoffman", "850", "Campuses",
"DC=CEC,DC=root,DC=careered,dc=com")
entry = New DirectoryEntry(strPath)
user = entry.Children.Add("CN=" & username, "User")
with User
.Properties("userPrincipalName").Add(String.Format("{0}@{1}", username,
"cec.root.careered.com"))
.Properties("sAMAccountName").Add(username)
.CommitChanges()
SetProperty(user, "mail", username & "@careered.com")
strExchangePath =
String.Format("CN={0},CN={1},CN=InformationStore,CN={2},CN=Servers,CN={3},CN=Administrative
Groups,CN={4},CN=Microsoft Exchange,CN=Services,CN=Configuration,{5}", "MS1",
"First Storage Group", "850EMX001", "CEC", "Careered",
"DC=root,DC=careered,DC=com")
Mailbox = DirectCast(user.NativeObject, CDOEXM.IMailboxStore)
Mailbox.CreateMailbox(strExchangePath)
user.CommitChanges()
end sub
trying to mail enable them. This code has worked for 18 months with very few
problems. Now there's a new twist. I have to create the user and mailbox in a
different domain than the one I'm running in. I impersonate a domain admin
in the domain. Everything works up to the point where it tries to create the
mailbox. Then I get a "Catastrophic failure" 0x8000FFFF error message. Does
anyone have any idea what could be wrong?
I've appended a sample of the code to the end of this message. All of the
LDAP strings have been checked by multiple pairs of eyes. They specify valid
containers in AD and valid stores in Exchange. And I've left out some
details such as exception handling and the code for impersonation for the
sake of brevity.
--
Candi
Private Sub Create()
Dim newIdentity As System.Security.Principal.WindowsIdentity = Nothing
Dim newContext As
System.Security.Principal.WindowsImpersonationContext = Nothing
newIdentity = GetWindowsIdentity(GetValueFromConfig("CECUser1"),
"CEC", GetValueFromConfigEncrypt("CECPassword1"))
newContext = newIdentity.Impersonate
CreateUser()
newContext.Undo
End Sub
Private Sub CreateUser
Dim entry As DirectoryEntry = Nothing
Dim user As DirectoryEntry = Nothing
Dim strPath As String = String.Empty
Dim strExchangePath As String = String.Empty
Dim Mailbox As CDOEXM.IMailboxStore
Dim username As String = "testUser"
strPath =
String.Format("LDAP://{0}/OU={1},OU={2},OU={3},OU={4},OU={5},{6}", dcName,
"Users", "OEG Staff", "Hoffman", "850", "Campuses",
"DC=CEC,DC=root,DC=careered,dc=com")
entry = New DirectoryEntry(strPath)
user = entry.Children.Add("CN=" & username, "User")
with User
.Properties("userPrincipalName").Add(String.Format("{0}@{1}", username,
"cec.root.careered.com"))
.Properties("sAMAccountName").Add(username)
.CommitChanges()
SetProperty(user, "mail", username & "@careered.com")
strExchangePath =
String.Format("CN={0},CN={1},CN=InformationStore,CN={2},CN=Servers,CN={3},CN=Administrative
Groups,CN={4},CN=Microsoft Exchange,CN=Services,CN=Configuration,{5}", "MS1",
"First Storage Group", "850EMX001", "CEC", "Careered",
"DC=root,DC=careered,DC=com")
Mailbox = DirectCast(user.NativeObject, CDOEXM.IMailboxStore)
Mailbox.CreateMailbox(strExchangePath)
user.CommitChanges()
end sub
--
Candi
Candi