Re: [PHP] Domain Controller Discovery in PHP

2010-09-28 Thread Robert Cummings

On 10-09-28 04:03 AM, Jason wrote:
> Hi Rob,
>
> I've checked a couple of windows machines (which I admit I had 
assumed you were running php on) and the ENV variable "USERDNSDOMAIN" is 
definitely what you need. If your php is running on linux, you'll need 
to find out the target windows domain some other way (user input/config 
file maybe?).

>
> The article is a Win2k based one - there is a link to the XP one in 
the top-right corner. However I read both and things haven't changed 
from a DNS point of view.

>
> Here's a code snippet for you (run on my network from a windows 
workstation)...

>
>  # assume $_SERVER["USERDNSDOMAIN"] is equal to "xxx.local".
>
> print_r( 
dns_get_record("_ldap._tcp.dc._msdcs.".$_SERVER["USERDNSDOMAIN"],DNS_SRV) );

> ?>
>
> And the output (edited for obvious reasons):
>
> Array
> (
> [0] => Array
> (
> [host] => _ldap._tcp.dc._msdcs.xxx.local
> [type] => SRV
> [pri] => 0
> [weight] => 100
> [port] => 389
> [target] => dc2.xxx.local
> [class] => IN
> [ttl] => 545
> )
>
> [1] => Array
> (
> [host] => _ldap._tcp.dc._msdcs.xxx.local
> [type] => SRV
> [pri] => 0
> [weight] => 100
> [port] => 389
> [target] => dc1.xxx.local
> [class] => IN
> [ttl] => 545
> )
>
> )

Hi Jason,

Your assumption was right, I am on a windows machine, Windows Server 
2003. I think I understand the problem better now though from your 
example. We're currently using PHP 5.2.12 (with an update imminent), but 
this doesn't come with dns_get_record() which became available for 
Windows with the 5.3.0 branch. That may account for the missing 
USERDNSDOMAIN entry. I'm currently pulling the info using an exec() and 
nslookup:


nslookup -type=SRV _ldap._tcp.dc._msdcs.%userdnsdomain%

It's not optimal, but it appears to suffice until we upgrade to the 5.3 
branch.


Cheers,
Rob.
--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Domain Controller Discovery in PHP

2010-09-28 Thread Jason
-Original Message-
From: Robert Cummings [mailto:rob...@interjinn.com] 
Sent: 27 September 2010 19:38
To: Jason
Cc: 'PHP General'
Subject: Re: [PHP] Domain Controller Discovery in PHP

On 10-09-27 11:26 AM, Jason wrote:
> Hi Rob,
>
> I believe you should be able to do this with nothing more than DNS (this is 
> how Windows clients do it).
>
> Once you have the DNS domain of the machine you're on 
> (_SERVER["USERDNSDOMAIN"]), query for SRV records called the following:
>
> Name: _ldap._tcp.dc._msdcs.
>
> That should return one or more records in the answer, each one will be the 
> FQDN of a domain controller.
>
> Additional info from the horses mouth: http://support.microsoft.com/kb/247811

Hi Jason,

Thanks for the info. I don't actually have that server field (maybe 
because the article is for windows 2000), but maybe I can use your info 
to get to the next step anyways.

Cheers,
Rob.
-- 


Hi Rob,

I've checked a couple of windows machines (which I admit I had assumed you were 
running php on) and the ENV variable "USERDNSDOMAIN" is definitely what you 
need. If your php is running on linux, you'll need to find out the target 
windows domain some other way (user input/config file maybe?).

The article is a Win2k based one - there is a link to the XP one in the 
top-right corner. However I read both and things haven't changed from a DNS 
point of view.

Here's a code snippet for you (run on my network from a windows workstation)...




And the output (edited for obvious reasons):


Array
(
[0] => Array
(
[host] => _ldap._tcp.dc._msdcs.xxx.local
[type] => SRV
[pri] => 0
[weight] => 100
[port] => 389
[target] => dc2.xxx.local
[class] => IN
[ttl] => 545
)
 
[1] => Array
(
[host] => _ldap._tcp.dc._msdcs.xxx.local
[type] => SRV
[pri] => 0
[weight] => 100
[port] => 389
[target] => dc1.xxx.local
[class] => IN
[ttl] => 545
)
 
)


HTH
J



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Domain Controller Discovery in PHP

2010-09-27 Thread Robert Cummings

On 10-09-27 11:26 AM, Jason wrote:

Hi Rob,

I believe you should be able to do this with nothing more than DNS (this is how 
Windows clients do it).

Once you have the DNS domain of the machine you're on 
(_SERVER["USERDNSDOMAIN"]), query for SRV records called the following:

Name: _ldap._tcp.dc._msdcs.

That should return one or more records in the answer, each one will be the FQDN 
of a domain controller.

Additional info from the horses mouth: http://support.microsoft.com/kb/247811


Hi Jason,

Thanks for the info. I don't actually have that server field (maybe 
because the article is for windows 2000), but maybe I can use your info 
to get to the next step anyways.


Cheers,
Rob.
--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Domain Controller Discovery in PHP

2010-09-27 Thread Jason
Hi Rob,

I believe you should be able to do this with nothing more than DNS (this is how 
Windows clients do it).

Once you have the DNS domain of the machine you're on 
(_SERVER["USERDNSDOMAIN"]), query for SRV records called the following:

Name: _ldap._tcp.dc._msdcs.
 
That should return one or more records in the answer, each one will be the FQDN 
of a domain controller.

Additional info from the horses mouth: http://support.microsoft.com/kb/247811

HTH
Jason

-Original Message-
From: Robert Cummings [mailto:rob...@interjinn.com] 
Sent: 27 September 2010 16:05
To: PHP General
Subject: [PHP] Domain Controller Discovery in PHP

Hello list,

Does anyone know a method in Windows Server 2003 to discover one or more 
domain controllers to which the machine is connected. I know as an 
administrator I can use dsquery and various other administrator 
commands, but I'm unsure how to do so within PHP from an unprivileged 
vantage point.

Thanks,
Rob.
-- 
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php