Hi all,
I am running the 6.0.1.1 version on Windows 2003 STD in large environment
I am trying to import computers from AD. So I follow this: File->Import->Import Computer Wizard->Active Directory
The result list does not include all computer accounts. I have 3107 computer accounts in this domain, should it be the reason?
If yes, How can I choose the OU or attribute to select only servers? By the way, Is it possible to import from a base OU and create Group/Folder in accordance with OU structure?
Regards,
Nikky
edited by Nikky on 4/7/2011
edited by Nikky on 4/7/2011
Hi,
We use the WMI api to list the computer, do you know if there could be something that does not list everything, are they on the same domain?
David Hervieux
Hi David,
I have tried a MMC query with AD Users and Computers snap-in (wich is using WMI ): (&(objectCategory=computer)(name=*)) on the same computer and same AD controller and I get a complete list.
Is this test is enough for you?
For your second question, yes, I am talking about all computer accounts of only one domain.
Regards,
I will try to send you a small application to do a test. I will try to do it this week. Thank you.
David Hervieux
Hi David,
I have tried this script:
Const ADS_SCOPE_SUBTREE = 2
Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCOmmand.ActiveConnection = objConnection
objCommand.CommandText = _
"Select Name, Location from 'LDAP://DC=fabrikam,DC=com' " _
& "Where objectClass='computer'"
objCommand.Properties("Page Size") = 1000
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst
Do Until objRecordSet.EOF
Wscript.Echo "Computer Name: " & objRecordSet.Fields("Name").Value
Wscript.Echo "Location: " & objRecordSet.Fields("Location").Value
objRecordSet.MoveNext
Loop
and it works as expected.
Just a question: are you using wmi "to verify" connectivity between the account you fund and the computer itself using Win32_ComputerSystem class? If yes, our firewalls rules/security policies can explain this problem...
edited by Nikky on 4/27/2011
Ok,
Sorry for the delay, can you try this executable?
The first button is similar to my original code and the second one is more like the script you gave me.
David Hervieux
ImportAD.zip
Hi David,
No problem for the delay...
Well, I was not able to verify the result because:
- The result window is not big enough to contain all lines. So I cannot see all results. Could you put the result in a grid control?
- The "new" button gave me this:
See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.
************** Exception Text **************
System.DirectoryServices.DirectoryServicesCOMException (0x8007202B): A referral was returned from the server.
at System.DirectoryServices.DirectoryEntry.Bind(Boolean throwIfFail)
at System.DirectoryServices.DirectoryEntry.Bind()
at System.DirectoryServices.DirectoryEntry.get_AdsObject()
at System.DirectoryServices.DirectorySearcher.FindAll(Boolean findMoreThanOne)
at System.DirectoryServices.DirectorySearcher.FindAll()
at ImportAD.Form1.LoadDomainComputers2(List`1 computers, String domainName)
at ImportAD.Form1.button2_Click(Object sender, EventArgs e)
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
************** Loaded Assemblies **************
mscorlib
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.3615 (GDR.050727-3600)
CodeBase: file:///C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/mscorlib.dll
----------------------------------------
ImportAD
Assembly Version: 1.0.0.0
Win32 Version: 1.0.0.0
CodeBase: file:///C:/sources/ImportAD.exe
----------------------------------------
System.Windows.Forms
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.3053 (netfxsp.050727-3000)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Windows.Forms/2.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
System
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.3614 (GDR.050727-3600)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
System.Drawing
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.3053 (netfxsp.050727-3000)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Drawing/2.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
----------------------------------------
System.Configuration
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.3053 (netfxsp.050727-3000)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Configuration/2.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll
----------------------------------------
System.Xml
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.3082 (QFE.050727-3000)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Xml/2.0.0.0__b77a5c561934e089/System.Xml.dll
----------------------------------------
System.DirectoryServices
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.3053 (netfxsp.050727-3000)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.DirectoryServices/2.0.0.0__b03f5f7f11d50a3a/System.DirectoryServices.dll
----------------------------------------
************** JIT Debugging **************
To enable just-in-time (JIT) debugging, the .config file for this
application or computer (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.
For example:
<configuration>
<system.windows.forms jitDebugging="true" />
</configuration>
When JIT debugging is enabled, any unhandled exception
will be sent to the JIT debugger registered on the computer
rather than be handled by this dialog box.
Regards,
edited by Nikky on 5/2/2011
Hi,
I modified the program, can you retry?
David Hervieux
ImportAD1.1.zip
David,
The Default button returns only 1000 entries. I am pretty sure it is because the page size is limited to 1000: http://support.microsoft.com/kb/315071 :
MaxPageSize - This value controls the maximum number of objects that are returned in a single search result, independent of how large each returned object is. To perform a search where the result might exceed this number of objects, the client must specify the paged search control. This is to group the returned results in groups that are no larger than the MaxPageSize value. To summarize, MaxPageSize controls the number of objects that are returned in a single search result.
Default value: 1,000
The "New" button returns 3134 entries what is my current number of computer accounts.
I have found for C# if this help:
public int TotalEnabledUsers
{
get
{
UserPrincipal user_principal = new UserPrincipal(principal_context);
user_principal.Enabled = true;
PrincipalSearcher principal_searcher = new PrincipalSearcher(user_principal);
principal_searcher.QueryFilter = user_principal;
(principal_searcher.GetUnderlyingSearcher() as DirectorySearcher).PageSize = max_page_size;
(principal_searcher.GetUnderlyingSearcher() as DirectorySearcher).SizeLimit = max_result_size;
int count = principal_searcher.FindAll().Count();
Console.WriteLine("Count:" + count);
return count;
}
}
Comment:"FindAll should do a paged search on it's own. We ran into some trouble when we set the PageSize to something really high (or if it wasn't set at all!) So we always set it to 1000. And with the .Net Framework 3.5 we had trouble with a memory leak when the Cache was activated. So we set CacheResults = false."
Regards,
edited by Nikky on 5/2/2011
Hi,
It's hard for me to test, but can you try this version:
David Hervieux
ImportAD1.2.zip
Hi David,
Same result...
Default = 1000 entries
New = 3135 (good result)
If you need to bulk import computer accounts into a test OU this is a sample:
The csv file:
Name,SamAccountName
computer1,computer1$
computer2,computer2$
The command is:
Import-Csv E:\Scripts\Computers.csv | ForEach-Object {New-QADObject -Name $_.Name -ParentContainer <Yourdomain.com>/Test/TestOU2 -Type 'computer' -ObjectAttributes @{userAccountControl=($_.userAccountControl -band 2);samAccountName=($_.samAccountName)}}
You need Powershell with active roles to run this script: http://www.quest.com/powershell/activeroles-server.aspx
Regards,
So, if I integrate the new button (I mean the new code) in RDM, it will work fine?
edited by dhervieux on 5/3/2011
David Hervieux
Yes, it will be the solution...
Great, this will be in the next release. I hope to release it in the next few weeks. We are nearly done with the Remote Desktop Manager Online 1.2 and RDM integrate it nicely.
David Hervieux