March 15

Create a Solution to Synchronize Account Expiry : Step 5 – Add new run profile

As next 4 run profiles need to be created:

  • Full Import
  • Full Synchronization
  • Delta Import
  • Delta Synchronization

The run profiles need to be created with exactly these run profile names, that the AAD Connect scheduler can pick up these run profiles.

Here are the steps how to create a new run profile:

  1. click on the connectors tab in the synchronization service manager, select our new connector AddRunProfile
  2. click on configure run profile CreateNewProfile
  3. This will open a new window where the list of the run profiles is empty, so click on “New Profile…” to add new run profileAddRunProfileNewProfile
  4. Where you need to add a display name for the new run profile. The name of the run profile should be capitalized and written as aboveAddNewRunProfile_ProfileName
  5. click on next, and select the type Full Import (Stage Only) AddNewRunProfile_ProfileType
  6. click on next, and you do not need to change anything in the following window AddNewRunProfile_ConnectorConfig
  7. click on finish
  8. Repeat this step for other run profiles as well.

 

 

And that’s it. All expired accounts will be disabled as wished. And this process works in delta mode.

Category: AAD Connect, AccountExpires | Comments Off on Create a Solution to Synchronize Account Expiry : Step 5 – Add new run profile
March 11

Create a Solution to Synchronize Account Expiry : Step 4 – Add Synchronization Rule for the new connector

After the new connector is created the next step is to create synchronization rules. Open the AAD Connect Synch Rules Editor and ensure that the inbound flow direction is selected. Click on new to create a new synchronization rule:

Add a name for example: Disabled expired accounts select the name of the created connector at connected system. The object type should be person for connected system object type and for metaverse object type as well. The rule type should be join and I’d suggest a precedence lower than 100. See you here:

 

AADC_CreateNewSynchRule_Description

 

 

The scoping filter can be empty, but we need to set up a join rule. We need here to select sourceAnchor to sourceAnchor. I do not recommend to use anything else.

 

AADC_CreateNewSynchRule_JoinRule

 

 

And now the highlight, the transformation. This should be a constant flow to accountEnabled with the constant value of FALSE.

 

AADC_CreateNewSynchRule_AddTransformation

 

 

Next: https://happyts.tech/create-a-solution-to-synchronize-account-expiry-step-5-add-new-run-profile/

Prev: https://happyts.tech/create-a-solution-to-synchronize-account-expiry-step-3-add-the-new-connector-to-aad-connect/

 

Category: AAD Connect, AccountExpires, ADSync | Comments Off on Create a Solution to Synchronize Account Expiry : Step 4 – Add Synchronization Rule for the new connector
March 7

Create a Solution to Synchronize Account Expiry : Step 3 – Add the new connector to AAD Connect

the next step is really exciting: add our new connector to AAD Connect:

  1. at first you need to copy the complied dll and pdb file in to the folder: C:\Program Files\Microsoft Azure AD Sync\Extensions AADC_AddFilesToExtensionsFolder
  2. As next Open the AAD Connect Synchronization Service Console
  3. Click on Connectors
  4. Click on Create AADC_CreateNewConnector
  5. Select the Connector Type: Extensible Connectivity 2.0 and Enter a Name for the connect e.g. 9th_AADC_CreateNewConnector_Name
  6. Click on Browse and select the Dll,: ExpiredAccountsConnector.dll and click  ok10th_AADC_CreateNewConnector_SelectDll
  7. On the page click on refresh interfaces 11th_AADC_CreateNewConnector_RefreshInterface
  8. Click on Next
  9. The next windows shows the partition, here just click on next, do not need to change anything  13th_AADC_CreateNewConnector_Partition
  10. Select the object:Person    14th_AADC_CreateNewConnector_ObjectType
  11. Select the Attributes (I’d recommend to select them all) 15th_AADC_CreateNewConnector_Attributes
  12. Click Next
  13. On the next page you will see the configuration of the anchor, you do not need to change this 16th_AADC_CreateNewConnector_Anchor
  14. Click Finish

 

Next: https://happyts.tech/create-a-solution-to-synchronize-account-expiry-step-4-add-synchronization-rule-for-the-new-connector/

Category: AAD Connect, AccountExpires, ADSync | Comments Off on Create a Solution to Synchronize Account Expiry : Step 3 – Add the new connector to AAD Connect
February 12

Create a Solution to Synchronize Account Expiry : Step 2 – Build a new connector (aka ManagementAgent)

Here is the source code for the connector, what will import the information about the expiry and looks like this:

 

AADC_SConsole_importedData

 

and here is the code, what you can compile using VisualStudio (community edition should work as well). You need to add the following dll as reference to the project:

C:\Program Files\Microsoft Azure AD Sync\Bin\Assemblies\Microsoft.MetadirectoryServicesEx.dll

you can find further information about the ECMA 2 API here:

https://docs.microsoft.com/en-us/previous-versions/windows/desktop/forefront-2010/hh859557(v=vs.100)?redirectedfrom=MSDN

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
using System;
using System.Text;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using Microsoft.MetadirectoryServices;
using System.Data.SqlClient;
using System.Data;
using System.Diagnostics;
using ConnectionState = System.Data.ConnectionState;


namespace AccountExpiredMA
{

        public class EzmaExtension :
        IMAExtensible2CallImport,      
         IMAExtensible2GetSchema,
         IMAExtensible2GetCapabilities,
         IMAExtensible2GetParameters
        {
            private int m_importDefaultPageSize = 12;
            private int m_importMaxPageSize = 50;

            SqlConnection conn;
            SqlCommand sqlCmd;

            private const string OBJECT_ID = "object_id";
            private const string OBJECT_TYPE = "object_type";
            private const string SOURCE_ANCHOR = "sourceAnchor";
            private const string DISPLAY_NAME = "displayName";
            private const string USER_PRINCIPAL_NAME = "userPrincipalName";
            private const string EXPIRY_ATTRIBUTE_KEY = "Metaverse Attribute for accountExpires";
            private const string DEFAULT_EXPIRY_ATTR = "extensionAttribute10";
            private const string EXPIRY_DATE = "expiryDate";
            private const string CURRENT_DATE = "currentDate";
            private const string EXPIRED = "expired";
            private const string SQL_SERVER_KEY = "SQL server";
            private const string SQL_SERVER_DB_KEY = "SQL Database";
            private string EXPIRY_ATTRIBUTE = DEFAULT_EXPIRY_ATTR;
            private string WATERMARK_ATTRIBUTE = "last_modification_date";
            private Schema currentSchema;
            private const string OBJECT_TYPE_PERSON = "Person";
            private const string TABLE_NAME = "expiredAccounts";


            //
            // Constructor
            //
            public EzmaExtension()
            {
                //
                // TODO: Add constructor logic here
                //
            }

            /// <summary>
            /// Capabilities of the Extensible MA
            /// </summary>
            public MACapabilities Capabilities
            {
                get
                {
                    MACapabilities myCapabilities = new MACapabilities();
                    myCapabilities.ConcurrentOperation = true;
                    myCapabilities.ObjectRename = false;
                    myCapabilities.DeleteAddAsReplace = true;
                    myCapabilities.DeltaImport = true;
                    myCapabilities.DistinguishedNameStyle = MADistinguishedNameStyle.None;
                    myCapabilities.NoReferenceValuesInFirstExport = false;
                    myCapabilities.Normalizations = MANormalizations.None;
                    myCapabilities.ObjectConfirmation = MAObjectConfirmation.Normal;
                    return myCapabilities;
                }
            }

            /// <summary>
            /// Parameter settings / configuration page of the Management Agent
            /// This function will be called for each of the pages
            /// </summary>
            /// <param name="configParameters"></param>
            /// <param name="page"></param>
            /// <returns></returns>
            public IList<ConfigParameterDefinition> GetConfigParameters(KeyedCollection<string, ConfigParameter> configParameters,
                                                                ConfigParameterPage page)
            {
                List<ConfigParameterDefinition> configParametersDefinitions = new List<ConfigParameterDefinition>();

                switch (page)
                {
                    case ConfigParameterPage.Connectivity:
                        configParametersDefinitions.Add(ConfigParameterDefinition.CreateStringParameter(SQL_SERVER_KEY, ""));
                        configParametersDefinitions.Add(ConfigParameterDefinition.CreateStringParameter(SQL_SERVER_DB_KEY, string.Empty,"ADSync"));
                        configParametersDefinitions.Add(ConfigParameterDefinition.CreateDividerParameter());
                        configParametersDefinitions.Add(ConfigParameterDefinition.CreateLabelParameter("Please enter the name of the metaverse attribute, what contains the expiry date."));
                        configParametersDefinitions.Add(ConfigParameterDefinition.CreateStringParameter(EXPIRY_ATTRIBUTE_KEY, string.Empty,DEFAULT_EXPIRY_ATTR));
                        break;


                    case ConfigParameterPage.Global: 
                        //// not required for our purposes
                        break;


                    case ConfigParameterPage.Partition:
                        //// partitioning is possible only with LDAP style DN
                        break;

                    case ConfigParameterPage.RunStep:
                        //// no additional setting is required here
                        break;
                }

                return configParametersDefinitions;
            }



            /// <summary>
            /// This function will be called if the parameters will be validated
            /// </summary>
            /// <param name="configParameters"></param>
            /// <param name="page"></param>
            /// <returns></returns>
            public ParameterValidationResult ValidateConfigParameters(KeyedCollection<string, ConfigParameter> configParameters,
                                                                       ConfigParameterPage page)
            {
                ParameterValidationResult myResults = new ParameterValidationResult();
                return myResults;
            }


            /// <summary>
            /// This function build the schema of the management agent. we have here a fixed schema.
            /// The objectType contains only person, the anchor attribute is fixed.
            /// But there is an option to select / unselect attributes
            /// </summary>
            /// <param name="configParameters"></param>
            /// <returns></returns>
            public Schema GetSchema(KeyedCollection<string, ConfigParameter> configParameters)
            {
                //// set the name of the Exipry attribute to the attribute, what is added on the config page
                EXPIRY_ATTRIBUTE = configParameters[EXPIRY_ATTRIBUTE_KEY].Value;

                //// create the object type in the schema: Person
                Microsoft.MetadirectoryServices.SchemaType personType = Microsoft.MetadirectoryServices.SchemaType.Create(OBJECT_TYPE_PERSON, true);

                //// create the schema attributes
                SchemaAttribute CS_ATTR_Anchor = SchemaAttribute.CreateAnchorAttribute(OBJECT_ID, AttributeType.String, AttributeOperation.ImportOnly);
                SchemaAttribute CS_ATTR_ObjectType = SchemaAttribute.CreateSingleValuedAttribute(OBJECT_TYPE, AttributeType.String, AttributeOperation.ImportOnly);
                SchemaAttribute CS_ATTR_DisplayName = SchemaAttribute.CreateSingleValuedAttribute(DISPLAY_NAME, AttributeType.String, AttributeOperation.ImportOnly);
                SchemaAttribute CS_ATTR_UserPrincipalName = SchemaAttribute.CreateSingleValuedAttribute(USER_PRINCIPAL_NAME, AttributeType.String, AttributeOperation.ImportOnly);
                SchemaAttribute CS_ATTR_sourceAnchor = SchemaAttribute.CreateSingleValuedAttribute(SOURCE_ANCHOR, AttributeType.String, AttributeOperation.ImportOnly);
                SchemaAttribute CS_ATTR_expired = SchemaAttribute.CreateSingleValuedAttribute(EXPIRED, AttributeType.String, AttributeOperation.ImportOnly);
                SchemaAttribute CS_ATTR_expiryAttribute = SchemaAttribute.CreateSingleValuedAttribute(EXPIRY_ATTRIBUTE, AttributeType.String, AttributeOperation.ImportOnly);
                SchemaAttribute CS_ATTR_ExpiryDate = SchemaAttribute.CreateSingleValuedAttribute(EXPIRY_DATE, AttributeType.String, AttributeOperation.ImportOnly);
                
                //// add the attributes to the object type
                personType.Attributes.Add(CS_ATTR_Anchor);
                personType.Attributes.Add(CS_ATTR_ObjectType);
                personType.Attributes.Add(CS_ATTR_DisplayName);
                personType.Attributes.Add(CS_ATTR_UserPrincipalName);
                personType.Attributes.Add(CS_ATTR_sourceAnchor);
                personType.Attributes.Add(CS_ATTR_expired);
                personType.Attributes.Add(CS_ATTR_expiryAttribute);
                personType.Attributes.Add(CS_ATTR_ExpiryDate);
                
                //// create the schema object
                Schema schema = Schema.Create();
                
                //// add the object type to the schema
                schema.Types.Add(personType);
                return schema;
            }



         /// <summary>
         ///  This is the first function what will be called during the import run-profile.
         ///  This function takes care about the connection to data source in our case to the sql database.
         /// </summary>
         /// <param name="configParameters">This collection contains the configured configuration data.</param>
         /// <param name="types">
         ///        This parameter contains the configured schema: selected object type - in our case person and the
         ///        selected attributes.
         /// </param>
         /// <param name="importRunStep">
         ///        This contains the run step, what contains also the information, 
         ///        if the running run profile delta import or full import.</param>
         /// <returns></returns>
            public OpenImportConnectionResults OpenImportConnection(
                                           KeyedCollection<string, ConfigParameter> configParameters,
                                           Schema types,
                                           OpenImportConnectionRunStep importRunStep)
            {
                WriteLog("Open Connection");

                ////    reading the data from the config parameter
                string myServer = configParameters[SQL_SERVER_KEY].Value;
                string myDB = configParameters[SQL_SERVER_DB_KEY].Value;

                ////    set the selected attribute for the expiry attribute
                string expiryMVAttr = configParameters[EXPIRY_ATTRIBUTE_KEY].Value;
                
                ////    set the global schema variable 
                currentSchema = types;

                ////    set up the SQL connection string
                string myConnection = $"Server = '{myServer}';Initial Catalog='{myDB}';Integrated Security=True";
                WriteLog($"connection string:{myConnection}");
                
                ////    set up the SQL connection
                conn = new SqlConnection(myConnection);
                sqlCmd = new SqlCommand();
                sqlCmd.CommandType = CommandType.Text;

                /// set up the SQL command, that is used to retrieve the data from the SQL table
                string cmdText = $@"
                Use ADsync;
                SELECT
                     [object_id]
                    ,[object_type]
                    ,[sourceAnchor]
                    ,[displayName]
	                ,[userPrincipalName]
	                ,[extensionAttribute10]
                    ,CAST( [{expiryMVAttr}] as date) as expiryDate
                    ,CAST(GETDATE() AS DATE) as currentDate
	                ,'TRUE' As expired
                    ,[last_modification_date]

                FROM[ADSync].[dbo].[mms_metaverse]

                WHERE
                    object_type = 'person'
                    AND {expiryMVAttr} is not null
                    AND(CAST( [{expiryMVAttr}] as date) < CAST(GETDATE() AS DATE) )
                    ";

                 ////   check if the select run profile is delta import and if there is a watermark (CustomData)
                  if (importRunStep.ImportType == OperationType.Delta && importRunStep.CustomData.Length > 0)
                  {
                    ////    retrieve the watermark and append to the SQL query  
                    string waterMark = Convert.ToString(importRunStep.CustomData);
                    if (!string.IsNullOrWhiteSpace(waterMark))
                    {
                        string deltaSuffix = $" AND (CAST( [{expiryMVAttr}] as date) >= '{waterMark}'";
                        cmdText += deltaSuffix;
                    }
                  }                  


                WriteLog($"Command text: {cmdText}");
                ////    set up the SQL command
                sqlCmd.CommandText = cmdText;
                sqlCmd.Connection = conn;

                ///     try to open the SQL connection
                try
                {
                    conn.Open();
                }
                catch (InvalidOperationException iopEx)
                {
                    throw new FailedConnectionException("Can't open connection to SQL Server!", iopEx);
                }
                catch (SqlException sqlEx)
                {
                    throw new FailedConnectionException("Can't open connection to SQL Server!", sqlEx);
                }
                catch (System.Configuration.ConfigurationException scceEx)
                {
                    throw new FailedConnectionException("Can't open connection to SQL Server!", scceEx);
                }            

                return new OpenImportConnectionResults();
            }


            /// <summary>
            /// this function is called after the connection is opened to retrieve the data
            /// </summary>
            /// <param name="importRunStep"></param>
            /// <returns></returns>
            public GetImportEntriesResults GetImportEntries(GetImportEntriesRunStep importRunStep)
            {
                GetImportEntriesResults importReturnInfo = new GetImportEntriesResults();
                List<CSEntryChange> csentries = new List<CSEntryChange>();
                
                ////    set up the SQL Data Adapter and fill the data set
                SqlDataAdapter adapter = new SqlDataAdapter(sqlCmd);
                DataSet da = new DataSet();
                adapter.Fill(da, TABLE_NAME);

                //// create a mapping table between column name and column id
                Dictionary<string, int> columnMapping = new Dictionary<string, int>();
                foreach (DataColumn column in da.Tables[TABLE_NAME].Columns)
                {
                    columnMapping.Add(column.ColumnName, column.Ordinal);
                }

                string currentWaterMark = string.Empty;

                ////    retrieve the configured schema for the object type person
                KeyedCollection<string, SchemaAttribute> selectedAttributes = currentSchema.Types[OBJECT_TYPE_PERSON].Attributes;


                ////    check if there are any results
                if (null != da.Tables && 0 < da.Tables.Count)
                {
                    WriteLog($"Nr of result: {da.Tables.Count} has been retrieved.");

                    ////    iterate through the result set
                    for (int indexOfResult = 0; indexOfResult <= da.Tables[TABLE_NAME].Rows.Count - 1; indexOfResult++)
                    {
                        //WriteLog($"Current: {indexOfResult} of result: {da.Tables.Count}");
                        ////    create the connector space object, that will be passed as return value to the sync engine
                        CSEntryChange cse = CSEntryChange.Create();
                        cse.ObjectModificationType = ObjectModificationType.Add;
                        cse.ObjectType = OBJECT_TYPE_PERSON;

                        ////    iterate through the columns
                        foreach (string columnName in columnMapping.Keys)
                        {
                            //WriteLog($"Current column: {columnName} ");
                            
                            ////    check if the current attribute is selected
                            if (selectedAttributes.Contains(columnName))
                            {
                                //WriteLog($"Current column is selected: {columnName} ");
                                ////    retrieve the value of the current and selected attribute
                                string attributeValue = RetrieveStringValueFromTable(ref da, ref indexOfResult, ref columnMapping, columnName);
                                if (!string.IsNullOrWhiteSpace(attributeValue))
                                {
                                    //WriteLog($"Current value is: {attributeValue} ");
                                    ////    the attribute value is not empty => add to the object
                                    cse.AttributeChanges.Add(AttributeChange.CreateAttributeAdd(columnName, attributeValue));
                                }
                            }                           
                        }

                        ///     add the connector space object to the result list
                        csentries.Add(cse);                        
                    }
                }
                else
                {
                    ////    the result list is empty
                    WriteLog($"No result has been retrieved.");
                }
                

                ////    set up the return info object the pass as return object
                importReturnInfo.CustomData = currentWaterMark;                
                importReturnInfo = new GetImportEntriesResults();
                importReturnInfo.MoreToImport = false;
                importReturnInfo.CSEntries = csentries;
                return importReturnInfo;
            }


            /// <summary>
            /// auxiliary function to read the object value from the given table
            /// </summary>
            /// <param name="da">DataSet that contains the retrieved data from SQL database</param>
            /// <param name="rowIndex">index of the current row in the data table</param>
            /// <param name="columnMapping">Dictionary that contains the mapping between column name and column index</param>
            /// <param name="attribute">contains the name of the current attribute</param>
            /// <returns></returns>
            private string RetrieveStringValueFromTable(ref DataSet da, ref int rowIndex, ref Dictionary<string, int> columnMapping, string attribute)
            {
               return Convert.ToString(da.Tables[TABLE_NAME].Rows[rowIndex].ItemArray.GetValue(columnMapping[attribute])).Trim();
            }

            
            /// <summary>
            /// after all data are retrieved, the connection needs to be closed
            /// </summary>
            /// <param name="importRunStepInfo"></param>
            /// <returns></returns>
            public CloseImportConnectionResults CloseImportConnection(CloseImportConnectionRunStep importRunStepInfo)
            {
                if (conn.State == ConnectionState.Open)
                {
                    try
                    {
                        conn.Close();
                    }
                    catch (SqlException sqlEx )
                    {
                        WriteLog($"Error while closing the SQL Connection. \n {sqlEx.Message}");
                    }
                }
                return new CloseImportConnectionResults();
            }


            /// <summary>
            /// This function returns the max possible import page size
            /// </summary>
            public int ImportMaxPageSize
            {
                get
                {
                    return m_importMaxPageSize;
                }
            }


            /// <summary>
            /// This function returns the default import page size
            /// </summary>
            public int ImportDefaultPageSize
            {
                get
                {
                    return m_importDefaultPageSize;
                }
            }

                
            /// <summary>
            /// This function writes message to the Windows Application Event log
            /// </summary>
            /// <param name="message">This is the message string, what will be written into the Application Event Log</param>
            internal void WriteLog(string message)
            {
                //EventLog.CreateEventSource("ADSync", "Application");
                EventLog objEvent = new EventLog();
                objEvent.Source = "ADSync";
                StringBuilder eventText = new StringBuilder();
                eventText.Append($"ExpireAccountsConnector: {message}");
                objEvent.WriteEntry(eventText.ToString(), EventLogEntryType.Information);
            }


        }
    
}

And if you wish to download the precompiled connector you can do this here:

ExpiredAccountsConnector

 

the next step is to create a connector: https://happyts.tech/create-a-solution-to-synchronize-account-expiry-step-3-add-the-new-connector-to-aad-connect/

Category: AAD Connect, AccountExpires, ADSync | Comments Off on Create a Solution to Synchronize Account Expiry : Step 2 – Build a new connector (aka ManagementAgent)
February 12

Create a Solution to Synchronize Account Expiry : Step 1 – Add a new custom synchronization rule

The very fist thing what you need to plan and decide what is the metaverse attribute, what will contains the date time value for accountExpires. The accountExpires attribute contains ticks, what needs to be converted to date time. For this, we can use the following expression:

IF(IsNull([accountExpires]),NULL,IIF([accountExpires]<9223372036854775807,CStr(DateFromNum([accountExpires])),NULL))

 

You can configure this using the AAD Connect Synchronization Rules editor. Launch this, and click on new:

 

1st_AADC_SREditor_AddNewRule

 

As next a new window appears and you need to select the on-premises Active Directory Connector (account forest) as connected system, select the object type user in the source system and person as metaverse object type. I’d suggest a name as Convert AccountExpires to Date or: In from AD – User AccountExpires conversion. I’d suggest here a low precedence.

 

2nd_AADC_SREditor_Description

 

Click on next to see the scoping filter, what you can either leave empty or you can scope of the users you whish to handle:

3rd_AADC_SREditor_Scoping

 

after clicking on next, you can configure the join rules, but I’d suggest to keep this empty:

 

4th_AADC_SREditor_Join

 

and the last most important part is the conversion it self. You need to select Expression as FlowType and the attribute what you identified to keep the converted value. I’d recommend here a single valued string attribute, e.g. extensionAttribute10

 

5th_AADC_SREditor_Transformation

 

 

After clicking on next a full synchronization on this connector is required to get this attribute filled.

 

An alternative method is to use PowerShell to create this synchronization rule. Here is the rule itself, but you need to replace the id of the connector:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
New-ADSyncRule  `
-Name 'Convert AccountExpires to Date' `
-Identifier 'b6da9d89-b9bc-451c-9b6a-f46256620f50' `
-Description '' `
-Direction 'Inbound' `
-Precedence 90 `
-PrecedenceAfter '00000000-0000-0000-0000-000000000000' `
-PrecedenceBefore '00000000-0000-0000-0000-000000000000' `
-SourceObjectType 'user' `
-TargetObjectType 'person' `
-Connector '<replace with connector guid>'`
-LinkType 'Join' `
-SoftDeleteExpiryInterval 0 `
-ImmutableTag '' `
-OutVariable syncRule


Add-ADSyncAttributeFlowMapping  `
-SynchronizationRule $syncRule[0] `
-Destination 'extensionAttribute10' `
-FlowType 'Expression' `
-ValueMergeType 'Update' `
-Expression 'IIF(IsNull([accountExpires]),NULL,IIF([accountExpires]<9223372036854775807,CStr(DateFromNum([accountExpires])),NULL))' `
-OutVariable syncRule


Add-ADSyncRule  `
-SynchronizationRule $syncRule[0]


Get-ADSyncRule  `
-Identifier 'b6da9d89-b9bc-451c-9b6a-f46256620f50'

 

next step: https://happyts.tech/create-a-solution-to-synchronize-account-expiry-step-2-create-a-new-connector-aka-managementagent/

Category: AAD Connect, AccountExpires | Comments Off on Create a Solution to Synchronize Account Expiry : Step 1 – Add a new custom synchronization rule
February 11

The way to AAD Connect

As I mentioned earlier here: https://happyts.tech/history-of-sync-tool/ AAD Connect has its root in FIM / MIM.

During the way of evolution to the current release of AAD Connect there were several steps:

Azure AD Connector for FIM this is an extension for FIM and works also with MIM (see further information here: https://docs.microsoft.com/en-us/previous-versions/mim/dn511002(v=ws.10)?redirectedfrom=MSDN)

The next version was a downloadable version of a customized FIM with the version: 4.3.647.0 was called WAAD Sync:

So far I remember this was special version what could be downloaded from the Office 365 (BPOS) Portal.

As you can see this suggest, that this is a MIM Version, but if we have a look on the MIM version release history page we can’t find this version there:

MIM release history

 

The MIM release history can be found here: https://docs.microsoft.com/en-us/microsoft-identity-manager/reference/version-history

So this is a kind of pre-release of DirSync (https://docs.microsoft.com/en-us/azure/active-directory/hybrid/reference-connect-dirsync-deprecated)

The next version of the sync tool was AADSync with the version number: 1.0.419.0911 this was released in Nov 2014 (https://docs.microsoft.com/en-us/azure/active-directory/hybrid/reference-connect-version-history-archive#104190911)

The first version of AAD Connect was released in June 2015 with the version number: 1.0.8641.0 ( https://docs.microsoft.com/en-us/azure/active-directory/hybrid/reference-connect-version-history-archive#1086410)

 

This is only a short overview only for informal purposes. I recommend to use the latest version of AAD Connect (currently 1.5.45.0). You can find the release history and the url to download the latest version here: https://docs.microsoft.com/en-us/azure/active-directory/hybrid/reference-connect-version-history

Happy Troubleshooting!

Category: AAD Connect, ADSync, Dir Sync, WAAD | Comments Off on The way to AAD Connect
February 8

Multi-valued attributes synchronized from on premises AD using AAD Connect

I saw a lot of questions and discussions about the synchronization of multivalued attributes via AAD. If we have a look on the metaverse schema of AAD Connect we can see a similar picture like this:

AADConnect MV Schema

As we can see there are a lot attributes, what are synchronized by AAD connect…..

Well there are mentioned usually Directory Extensions. The synchronization of additional attributes is configured fast and easily. See the documentation on this here: https://docs.microsoft.com/en-us/azure/active-directory/hybrid/how-to-connect-sync-feature-directory-extensions

Here is the corresponding page of the AAD Connect Wizard:

As you can see here, there is nothing there to identify multi valued attributes here. This would be probably something for improvement….

The question is how to identify if an attribute a multi valued attribute?

1st Option: Using the Active Directory Users and Computers Console (dsa.msc)

one typical attribute is otherPhone. When we have a look on the attribute Editor, then we’ll see that a multi value attribute editor window is appearing:

2nd Option: Using the public documentation of the on-premises Active Directory schema:

https://docs.microsoft.com/en-us/windows/win32/adschema/attributes-all

 

Why is this so interesting?

Because Azure AD does not supports multi valued attributes as Directory Extensions as documented here:

 

There is an Azure Feedback to this topic: https://feedback.azure.com/forums/169401-azure-active-directory/suggestions/32622497-support-for-multi-valued-attributes-synchronized-f

Happy Troubleshooting!

Category: AAD Connect, DirectoryExtension, MultiValuedAttribute, Uncategorized | Comments Off on Multi-valued attributes synchronized from on premises AD using AAD Connect
February 4

AAD Connect and SIP Address synchronization

I saw several discussions about the synchronization of the SIP address from on-premises Active Directory to Azure AD using AAD. I saw some complains, that SIP addresses should be synchronized using the proxyAddresses attribute, precisely if the proxyAddresses attribute contains a SIP addresses then AAD Connect synchronizes this to Azure AD and the expectation is that this SIP-proxyAddress should be used as SIP addresses in Azure AD and Teams. Huh. Is this really so?

I think it’s worth to have a look on the description of the messaging schema. I can see there a description for proxyAddresses:

ProxyAddresses This existing Active Directory multi-valued attribute is part of the base Active Directory schema introduced in Windows 2000. This attribute contains the various X400, X500, and SMTP addresses of the user’s email. In Live Communications Server 2003 and later, the user’s SIP URI is added to this list, using the “sip:” tag.
The following applications search the user’s SIP URI from this attribute:
Microsoft Office Outlook 2003 messaging and collaboration client
Microsoft Office SharePoint Server 2007

https://docs.microsoft.com/en-us/skypeforbusiness/schema-reference/active-directory-schema-extensions-classes-and-attributes/schema-attributes-and-descriptions

Based this we can see, that the SIP addresses is added to this attribute, but this does not seems to be main source for this attribute. Let’s have a look on msRTCSIP-PrimaryUserAddress:

 

msRTCSIP-PrimaryUserAddress This attribute contains the SIP address of a given user.

https://docs.microsoft.com/en-us/skypeforbusiness/schema-reference/active-directory-schema-extensions-classes-and-attributes/schema-attributes-and-descriptions

 

Summarize, we can conclude that the important attribute what contains the SIP address is: msRTCSIP-PrimaryUserAddress…. hmmm, but this attribute is not present in your AD? Well this is possible, because this is messaging (Office Communication Server, Lync or Skype for Business) related schema extension. You can install the Active Directory schema extension using a Skype for Business Server 2019 installer (trial work as well). You can find a trial version in the eval center:

https://www.microsoft.com/en-us/evalcenter/evaluate-skype-business-server-2019/

The schema extension can be installed without installing the Skype for Business Server 2019, as described here:

Skype for Business Server is tightly integrated with Active Directory Domain Services (AD DS). Before Skype for Business Server can be installed for the first time, Active Directory must be prepared. The section of the Deployment Wizard titled Prepare Active Directory prepares the Active Directory environment for use with Skype for Business Server.

https://docs.microsoft.com/en-us/skypeforbusiness/deploy/install/prepare-active-directory#prepare-active-directory

 

If this schema extension is installed, then AAD Connect detects this and some additional rules will be added to the Sync rule editor: In from AD – User Lync

and Out to AAD – User Lync. Similar rules will be added also for contact and group objects. On this way the SIP address can be managed from on-premises Active Directory.

 

If the messaging schema is not present but the sip addresses is added to the proxyAddresses attribute AAD Connect will this synchronize to Azure AD, but the sip-proxyAddress will be ignored, since there is no authoritative source for the SIP address.

What happens, if a teams license will be assigned?

Nothing special, if the sip address is synchronized with an authoritative source (using: msRTCSIP-PrimaryUserAddress) then this address will be used. If there is no authoritative source for the sip address, then the SIP address will be generated on a basis of the userPrincipalName. If the userPrincipalName is the same as the sip-proxyAddress then this might suggest as the sip-proxyAddress is used, but this is not the case.

I hope this helps to understand how the synchronization of the SIP address is intended to work.

 

Happy Troubleshooting!

Category: AAD Connect, msRTCSIP-PrimaryUserAddress, ProxyAddresses, SIP Address | Comments Off on AAD Connect and SIP Address synchronization
January 28

AccountExpire is not synchronized by AAD Connect

I see, that a lot of people has some pain to synchronized the Account Expiry from on-premises Active Directory to Azure AD using AAD Connect.

There are two or more requests on this topic:

https://feedback.azure.com/forums/169401-azure-active-directory/suggestions/31459621-sync-account-expired-useraccountcontrol-to-azure

and

https://office365.uservoice.com/forums/289138-office-365-security-compliance/suggestions/17643847-active-directory-accountexpires-attribute-does-not

 

The reason for this is, that AAD Connect picks up changes from the on-prem AD and the AccountExpires attribute is a static attribute, where you can configure a dateTime (as ticks), when the account should expire. If this date is reached then the account is expired, but there is no change on the object itself. As we know, AAD Connect works state based, this means, AAD Connect picks up changes using the DirSyncControl. Since there is no change on the object, because the configured date on the object itself is static date and this date is reached, there is no change to pick up by AAD Connect. This is the reason, why AAD Connect can’t sync this change.

 

There are some documented workarounds, but these either requires a script that runs regularly (at least once a day) as mentioned here:

https://docs.microsoft.com/en-us/archive/blogs/undocumentedfeatures/use-aad-connect-to-disable-accounts-with-expired-on-premises-passwords

 

or the other solution, what required to run the full sync run profile on the on-prem AD Connector at least once a day:

https://myserverissick.com/2019/01/how-to-make-azure-ad-connect-disable-expired-accounts/

 

I think, that the best solution for this issue is to add a new connector (management agent), where this agent can calculate and populate this value. I’ll evaluate this option and will publish here soon……

 

Happy Troubleshooting!

Category: AAD Connect, AccountExpires | Comments Off on AccountExpire is not synchronized by AAD Connect
January 28

Run profiles

Import

read data from the connected data source and store in Connector space (kind of mirroring) . This can be delta or full. Delta imports only the changes since the last successfully finished delta import. Full imports all of the objects (in scope).

Please keep in mind, that confidential attributes won’t be imported by AAD Connect, since these are protected attributes:

https://docs.microsoft.com/en-us/troubleshoot/windows-server/windows-security/mark-attribute-as-confidential

the important message is:

“Active Directory performs a read access check on an object in the following cases:

When you evaluate whether the object matches the search filter.
When you return attributes of an object that match the search filter. By default, only administrators have CONTROL_ACCESS permissions to all objects. Therefore, only Administrators can read confidential attributes. Administrators may delegate these permissions to any user or to any group.”

from:https://docs.microsoft.com/en-us/troubleshoot/windows-server/windows-security/mark-attribute-as-confidential

 

If a deny ACL is applied on an attribute or on the object for the AAD Connect connector account, then AAD Connect won’t import the object or attribute as well.

 

Synchronization:

Calculation of the changes based on the configured synchronization rules. The inbound and outbound rules will be applied in this step:

source connector space object = inbound rules => metaverse object = outbound synchronization rules => destination connector space (object)

This step can be also delta or full. Delta means, that only the imported changes (see delta import) will be processed.

During the full synchronization all inbound and outbound synchronization rules will be applied again. The changes will be stored in the destination connector space and the state of the destination object will be pending export (can be add, modify or delete).

 

Export:

Only this steps touches the destination connected data source. The calculated changes will be exported to the destination. In case of AAD Connect this is Azure AD.

 

Happy Troubleshooting!

Category: AAD Connect, Logical processes | Comments Off on Run profiles