Well, you dont tell us where the exception is coming from, so ...
I'd step through the code and check in particular to see if this
DirectoryEntry rootEntry = new DirectoryEntry("LDAP://some.ldap.server.com");
rootEntry is null after that call - you might need to specify that connection like
DirectoryEntry rootEntry = new DirectoryEntry("LDAP://some.ldap.server.com","userid","password");
it goes without saying, that these entries :-
"LDAP://some.ldap.server.com"
"userid"
"password"
must be correct for your LDAP/AD server (I hope you just changed 'some.ldap.server.com' for the purposes of displaying the code here)
btw this syntax is 'better' ie to release the connection and tidy up the directory entries
using (DirectoryEntry ...
{
...
}
You might also need to specify the LDAP Connection like this and/or supply a target OU from where to search "LDAP://CN=server,DC=domain,DC=com"