removed unused vars from System.DirectoryServices.AccountManagement (#34159)
authorStefan Nikolei <stefan@nikolei.eu>
Fri, 10 Apr 2020 23:34:21 +0000 (01:34 +0200)
committerGitHub <noreply@github.com>
Fri, 10 Apr 2020 23:34:21 +0000 (16:34 -0700)
* removed unused vars from System.DirectoryServices.AccountManagement

removed all unused locals and class variables. also added some _ to out vars

* fix build errors.

removed assignments to non existent vars
added one var back because it was used

* remove trailing whitespace

src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/AD/ADStoreCtx.cs
src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/AuthZSet.cs
src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/SAM/SAMMembersSet.cs
src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/SAM/SAMStoreCtx_LoadStore.cs
src/libraries/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/SAM/SAMUtils.cs
src/libraries/System.DirectoryServices/src/System/DirectoryServices/ActiveDirectory/ConfigSet.cs

index 1871147..ea8490e 100644 (file)
@@ -1762,7 +1762,6 @@ namespace System.DirectoryServices.AccountManagement
             }
 
             Debug.Assert(g.UnderlyingObject != null && g.UnderlyingObject is DirectoryEntry);
-            UnsafeNativeMethods.IADsGroup adsGroup = (UnsafeNativeMethods.IADsGroup)((DirectoryEntry)g.UnderlyingObject).NativeObject;
             IEnumerable cachedMembersEnum = null; //This variables stores a reference to the direct members enumerator of the group.
 
             // Only real principals can be directly a member of the group, since only real principals
@@ -2232,44 +2231,6 @@ namespace System.DirectoryServices.AccountManagement
         {
             GlobalDebug.WriteLineIf(GlobalDebug.Info, "ADStoreCtx", "LoadDirectoryEntryAttributes, path={0}", de.Path);
 
-            string[] ldapAttributesUsed = new string[]
-            {
-                "accountExpires",
-                "badPasswordTime",
-                "badPwdCount",
-                "displayName",
-                "distinguishedName",
-                "description",
-                "employeeID",
-                "givenName",
-                "groupType",
-                "homeDirectory",
-                "homeDrive",
-                "lastLogon",
-                "lastLogonTimestamp",
-                "lockoutTime",
-                "logonHours",
-                "mail",
-                "member",
-                "memberOf",
-                "middleName",
-                "msDS-User-Account-Control-Computed",
-                "ntSecurityDescriptor",
-                "objectClass",
-                "objectGuid",
-                "objectSid",
-                "primaryGroupID",
-                "pwdLastSet",
-                "samAccountName",
-                "scriptPath",
-                "servicePrincipalName",
-                "sn",
-                "telephoneNumber",
-                "userAccountControl",
-                "userCertificate",
-                "userPrincipalName",
-                "userWorkstations"
-            };
             try
             {
                 //            de.RefreshCache(ldapAttributesUsed);
index 6ec5eef..0f9a955 100644 (file)
@@ -32,7 +32,6 @@ namespace System.DirectoryServices.AccountManagement
                                     userStoreCtx.GetType());
 
             _userType = userStoreCtx.OwningContext.ContextType;
-            _userCtxBase = userCtxBase;
             _userStoreCtx = userStoreCtx;
             _credentials = credentials;
             _contextOptions = contextOptions;
@@ -44,8 +43,6 @@ namespace System.DirectoryServices.AccountManagement
             // Preload the PrincipalContext cache with the user's PrincipalContext
             _contexts[flatUserAuthority] = userStoreCtx.OwningContext;
 
-            IntPtr hUser = IntPtr.Zero;
-
             //
             // Get the SIDs of the groups to which the user belongs
             //
@@ -541,9 +538,6 @@ namespace System.DirectoryServices.AccountManagement
         // The user's options
         private readonly ContextOptions _contextOptions;
 
-        // The ctxBase (e.g., DirectoryEntry) from the user's StoreCtx
-        private readonly object _userCtxBase;
-
         // The type (domain, local, etc.) of the user
         private readonly ContextType _userType;
 
index b8f97db..008b114 100644 (file)
@@ -26,7 +26,6 @@ namespace System.DirectoryServices.AccountManagement
                                     ctxBase.Path);
 
             _storeCtx = storeCtx;
-            _ctxBase = ctxBase;
 
             _group = group;
             _originalGroup = group;
@@ -101,8 +100,6 @@ namespace System.DirectoryServices.AccountManagement
             {
                 needToRetry = false;
 
-                object[] nativeMembers = new object[1];
-
                 bool f = _membersEnumerator.MoveNext();
 
                 if (f) // got a value
@@ -407,17 +404,15 @@ namespace System.DirectoryServices.AccountManagement
             bool isLocal = false;
 
             // Ask the OS to resolve the SID to its target.
-            int accountUsage = 0;
-            string name;
             string domainName;
 
             int err = Utils.LookupSid(
                                 _storeCtx.MachineUserSuppliedName,
                                 _storeCtx.Credentials,
                                 sid,
-                                out name,
+                                out _,
                                 out domainName,
-                                out accountUsage);
+                                out _);
 
             if (err != 0)
             {
@@ -577,7 +572,6 @@ namespace System.DirectoryServices.AccountManagement
         private bool _disposed = false;
 
         private readonly SAMStoreCtx _storeCtx;
-        private readonly DirectoryEntry _ctxBase;
 
         private bool _atBeginning = true;
 
index 92bf5b8..de42cce 100644 (file)
@@ -485,11 +485,10 @@ namespace System.DirectoryServices.AccountManagement
 
             string name;
             string domainName;
-            int accountUsage;
 
             // Map the SID to a machine and account name
             // If this fails, there's no match
-            int err = Utils.LookupSid(this.MachineUserSuppliedName, _credentials, sid, out name, out domainName, out accountUsage);
+            int err = Utils.LookupSid(this.MachineUserSuppliedName, _credentials, sid, out name, out domainName, out _);
 
             if (err != 0)
             {
@@ -784,7 +783,6 @@ namespace System.DirectoryServices.AccountManagement
         {
             byte[] sid = (byte[])de.Properties["objectSid"][0];
 
-            string stringizedSid = Utils.ByteArrayToString(sid);
             string sddlSid = Utils.ConvertSidToSDDL(sid);
             SecurityIdentifier SidObj = new SecurityIdentifier(sddlSid);
             p.LoadValueIntoProperty(propertyName, (object)SidObj);
index 54a65cb..37abbd1 100644 (file)
@@ -94,8 +94,6 @@ namespace System.DirectoryServices.AccountManagement
 
         internal static Principal DirectoryEntryAsPrincipal(DirectoryEntry de, StoreCtx storeCtx)
         {
-            string className = de.SchemaClassName;
-
             // Unlike AD, we don't have to worry about cross-store refs here.  In AD, if there's
             // a cross-store ref, we'll get back a DirectoryEntry of the FPO object.  In the WinNT ADSI
             // provider, we'll get back the DirectoryEntry of the remote object itself --- ADSI does
index bcd36bf..675a72e 100644 (file)
@@ -437,7 +437,6 @@ namespace System.DirectoryServices.ActiveDirectory
             try
             {
                 string entryName = (string)rootEntry.Properties["distinguishedName"].Value;
-
                 // Search for computer "serviceConnectionObjects" where the keywords attribute
                 // contains the specified keyword
                 // set up the searcher object