internal static void InsertPrincipal(Principal p, StoreCtx storeCtx, SDSUtils.GroupMembershipUpdater updateGroupMembership, NetCred credentials, AuthenticationTypes authTypes, bool needToSetPassword) { if (p as UserPrincipal != null || p as GroupPrincipal != null || p as AuthenticablePrincipal != null || p as ComputerPrincipal != null) { SDSUtils.ApplyChangesToDirectory(p, storeCtx, updateGroupMembership, credentials, authTypes); if (needToSetPassword && p.GetChangeStatusForProperty("AuthenticablePrincipal.PasswordInfo.Password")) { string valueForProperty = (string)p.GetValueForProperty("AuthenticablePrincipal.PasswordInfo.Password"); storeCtx.SetPassword((AuthenticablePrincipal)p, valueForProperty); } if (p.GetChangeStatusForProperty("AuthenticablePrincipal.PasswordInfo.ExpireImmediately")) { bool flag = (bool)p.GetValueForProperty("AuthenticablePrincipal.PasswordInfo.ExpireImmediately"); if (flag) { storeCtx.ExpirePassword((AuthenticablePrincipal)p); } } return; } else { object[] str = new object[1]; str[0] = p.GetType().ToString(); throw new InvalidOperationException(string.Format(CultureInfo.CurrentCulture, StringResources.StoreCtxUnsupportedPrincipalTypeForSave, str)); } }
internal static void ApplyChangesToDirectory(Principal p, StoreCtx storeCtx, SDSUtils.GroupMembershipUpdater updateGroupMembership, NetCred credentials, AuthenticationTypes authTypes) { DirectoryEntry native = (DirectoryEntry)storeCtx.PushChangesToNative(p); try { native.CommitChanges(); } catch (COMException cOMException1) { COMException cOMException = cOMException1; throw ExceptionHelper.GetExceptionFromCOMException(cOMException); } if (p as GroupPrincipal != null && p.GetChangeStatusForProperty("GroupPrincipal.Members")) { updateGroupMembership(p, native, credentials, authTypes); } }