Monday, February 13, 2012

available servers in domain

Hi, all
How do I findout available sql servers in the domain?.
Thanks in advancefrom command line type:
osql -L
--
-Vishal
"new" <henry_lin@.yahoo.com> wrote in message
news:#NVEuDsUDHA.1688@.TK2MSFTNGP11.phx.gbl...
> Hi, all
> How do I findout available sql servers in the domain?.
> Thanks in advance
>|||I'm not sure but i doubt it will list the server that is in another domain
though it is trusted.
--
-Vishal
"new" <henry_lin@.yahoo.com> wrote in message
news:u$6FKgsUDHA.2364@.TK2MSFTNGP09.phx.gbl...
> there is another way that I could find out?
> I need check how many sql servers in a trusted domain.
> Do I have to login that domain in order to find out?
> Thanks
> "new" <henry_lin@.yahoo.com> wrote in message
> news:#NVEuDsUDHA.1688@.TK2MSFTNGP11.phx.gbl...
> > Hi, all
> >
> > How do I findout available sql servers in the domain?.
> >
> > Thanks in advance
> >
> >
>|||Small VB function that will return just that.
Private Const SV_TYPE_SQLSERVER As Long = &H4
Private Type SERVER_INFO_100
sv100_platform_id As Long
sv100_name As Long
End Type
Private Declare Function NetApiBufferFree Lib "netapi32" (ByVal Buff As
Long) As Long
Private Declare Function NetServerEnum Lib "netapi32" (ByVal servername
As String, ByVal level As Long, bufptr As Long, ByVal prefmaxlen As
Long, entriesread As Long, totalentries As Long, ByVal servertype As
Long, ByVal Domain As String, resume_handle As Long) As Long
Private Declare Function SysAllocString Lib "oleaut32" (ByVal Source As
Long) As String
Private Declare Function MoveMemory Lib "kernel32" Alias "RtlMoveMemory"
(Dest As Any, Source As Any, ByVal Size As Long) As Long
'Enumerates Servers on a network
Private Function EnumSQLServers() As Variant
Dim lngType As Long
Dim lngSize As Long
Dim lngTotal As Long
Dim hResume As Long
Dim pBuf As Long
Dim arrServers() As SERVER_INFO_100
Dim arrNames As Variant
lngType = SV_TYPE_SQLSERVER
NetServerEnum vbNullString, 100, pBuf, -1, lngSize, lngTotal,
lngType, vbNullString, hResume
ReDim arrServers(lngSize - 1)
MoveMemory arrServers(0), ByVal pBuf, lngSize * Len(arrServers(0))
NetApiBufferFree pBuf
ReDim arrNames(lngSize - 1) As String
For lngTotal = 0 To lngSize - 1
arrNames(lngTotal) =StrConv(SysAllocString(arrServers(lngTotal).sv100_name), vbFromUnicode)
Next
EnumSQLServers = arrNames
End Function
Vishal Parkar wrote:
> I'm not sure but i doubt it will list the server that is in another domain
> though it is trusted.
> --
> -Vishal
> "new" <henry_lin@.yahoo.com> wrote in message
> news:u$6FKgsUDHA.2364@.TK2MSFTNGP09.phx.gbl...
>>there is another way that I could find out?
>>I need check how many sql servers in a trusted domain.
>>Do I have to login that domain in order to find out?
>>Thanks
>>"new" <henry_lin@.yahoo.com> wrote in message
>>news:#NVEuDsUDHA.1688@.TK2MSFTNGP11.phx.gbl...
>>Hi, all
>>How do I findout available sql servers in the domain?.
>>Thanks in advance
>>
>>
>

No comments:

Post a Comment