Previous Thread:   MIIS - 2 cpus or 1?

4/27/2006 3:07:28 PM    howto question
Hi all,  
  
I am working on MIIS, I have a lot of the concept in place, but now I have a  
  
problem: I have a provisioning extension for AD: this creates accounts and  
  
mailenables those accounts when in de SQL database the email attribute is  
  
set to yes. then the attribute flow is reversed, and the mail attribute (now  
  
the proper e-mail address) is flowed back into de SQL DB.  
  
when I want to enable an existing user (who previously had no mail address  
  
in AD) I want to use the "same" method of doing so: enter a yes in the SQL  
  
DB column, and let MIIS do the trick. I cannot get it to work: the extension  
  
I created does not work (because I use the wrong method off ExchangeUtils)  
  
but I cannot figure out a way of mailenabling an existing user in MIIS short  
  
of running a script from MIIS, that enables the user through adsi.  
  
Public Sub MapAttributesForExport(ByVal FlowRuleName As String, ByVal  
  
mventry As MVEntry, ByVal csentry As CSEntry) Implements  
  
IMASynchronization.MapAttributesForExport  
  
Const UF_SCRIPT = &H1  
  
Const UF_ACCOUNTDISABLE = &H2  
  
Const UF_HOMEDIR_REQUIRED = &H8  
  
Const UF_LOCKOUT = &H10  
  
Const UF_PASSWD_NOTREQD = &H20  
  
Const UF_PASSWD_CANT_CHANGE = &H40  
  
Const UF_ENCRYPTED_TEXT_PASSWORD_ALLOWED = &H80  
  
Const UF_TEMP_DUPLICATE_ACCOUNT = &H100  
  
Const UF_NORMAL_ACCOUNT = &H200  
  
Select Case FlowRuleName  
  
Case "userAccountControl"  
  
Dim currentValue As Long  
  
If csentry("userAccountControl").IsPresent Then  
  
currentValue =  
  
csentry("userAccountControl").IntegerValue  
  
Else  
  
currentValue = UF_NORMAL_ACCOUNT  
  
End If  
  
Select Case mventry("employeeStatus").Value.ToLower  
  
Case "active"  
  
csentry("userAccountControl").IntegerValue =  
  
(currentValue Or UF_NORMAL_ACCOUNT) And (Not UF_ACCOUNTDISABLE)  
  
Case Else  
  
csentry("userAccountControl").IntegerValue =  
  
currentValue Or UF_ACCOUNTDISABLE  
  
End Select  
  
Case "mailModify"  
  
Dim test As String = mventry("mail").Value  
  
If (mventry("mail").Value.ToLower = "yes") Then  
  
If (mventry("source").Value.ToLower = "employee") Then  
  
Dim Connected_AD_MA As ConnectedMA  
  
Dim dn As ReferenceValue  
  
Dim rdn As String  
  
Dim myConnector As CSEntry  
  
Dim nickName As String  
  
Dim SMTPAdres As String  
  
Const pstrAD_MA_Name = "Fabrikam AD MA"  
  
Const pstrAD_CD_ParentContainer =  
  
"OU=Employees,OU=Fabrikam,DC=fabrikam,DC=com"  
  
Const AD_MailMDB = "CN=Mailbox Store  
  
(LON-MIIS),CN=First Storage  
  
Group,CN=InformationStore,CN=LON-MIIS,CN=Servers,CN=First Administrative  
  
Group,CN=Administrative Groups,CN=FabrikamOrg,CN=Microsoft  
  
Exchange,CN=Services,CN=Configuration,DC=fabrikam,DC=com"  
  
Connected_AD_MA =  
  
mventry.ConnectedMAs(pstrAD_MA_Name)  
  
rdn = "CN=" + mventry("cn").Value  
  
dn =  
  
Connected_AD_MA.EscapeDNComponent(rdn).Concat(pstrAD_CD_ParentContainer)  
  
nickName = mventry("samAccountname").Value  
  
'below is the first attempt, which for obvious  
  
reasons does not work (the user already exists.)  
  
'csentry =  
  
ExchangeUtils.CreateMailbox(Connected_AD_MA, dn, nickName, AD_MailMDB)  
  
'the below entry does also (for the same reason I  
  
think) not work  
  
csentry =  
  
ExchangeUtils.CreateMailEnabledUser(Connected_AD_MA, dn, nickName, nickName  
  
+ "@fabrikam.com")  
  
csentry("description").Value = "Email later enabled  
  
"  
  
End If  
  
End If  
  
Case Else  
  
' TODO: remove the following statement and add your default  
  
script here  
  
Throw New EntryPointNotImplementedException  
  
End Select  
  
End Sub  
  
Thanks in Advance  
  
Eric Denekamp