Quantcast
Channel: Project Customization and Programming forum
Viewing all articles
Browse latest Browse all 5347

Deactivate users who are no longer exist in AD but were added into resource pool

$
0
0

Hello forum members,

does anyone know how to deactivate users who are no longer exist in AD , but were added into resource pool?

I an trying to write some code that would update a custom value for each resource, but my code breaks whenever it encounters a resource that is not longer exists in AD. Any suggestions are appreciated.

                                                                                     

  // Modify the resources, code was taken from http://msdn.microsoft.com/en-us/library/websvcresource.resource.updateresources(v=office.12).ASPX

                foreach (SvcResource.ResourceDataSet.ResourcesRow resourceRow in resourceDs.Resources)
                {
                    Console.WriteLine("Check out " + resourceRow.RES_NAME);
                    if (resourceRow.IsRES_CHECKOUTBYNull())
                    {
                        resourceSvc.CheckOutResources(new Guid[] { resourceRow.RES_UID });
                        checkedOut = true;
                    }
                    else
                    {
                        if (resourceRow.RES_CHECKOUTBY == me)
                        {
                            checkedOut = true;
                        }
                        else
                        {
                            checkedOut = false;
                            Console.WriteLine("\tCan't check out this resource, skip updating this one.");
                        }
                    }
                    if (checkedOut)
                    {
                        SvcResource.ResourceDataSet updateDs = resourceSvc.ReadResource(resourceRow.RES_UID);


                            if (resourceRow.RES_TYPE <= (int)PSLibrary.Resource.Type.INACTIVATED_OFFSET)
                            {


                                updateDs.Resources[0].RES_CODE = "A" + rand.Next(1000, 9999);
                                Console.WriteLine("Update RES_CODE to " + updateDs.Resources[0].RES_CODE);
                                resourceSvc.UpdateResources(updateDs, false, false);
                                Console.WriteLine("Check in " + resourceRow.RES_NAME);
                                resourceSvc.CheckInResources(new Guid[] { resourceRow.RES_UID }, false);

                            }


                    }

                    Console.ForegroundColor = ConsoleColor.Yellow;
                    Console.WriteLine("".PadRight(30, '-'));
                    Console.ResetColor();
                }


tatiana


Viewing all articles
Browse latest Browse all 5347

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>