Hi,
Is there a wahy to get AD user info in a SP?
I need a list of AD users with name, login name and email.
Thanks.
George.Hi.
I think there is not a function or something like that in SQL2005 that
retrieve all user from you Active Domain Controler (I'm not quiet sure about
that).
You can only get information abour your principals:
SELECT * FROM sys.server_principals
SELECT suser_name()
For advanced solution you must use CLR to get information about Active
Domain users.
Mladen.
"Microsoft" <g2@.bla.cl> wrote in message
news:OzjHniWOHHA.3668@.TK2MSFTNGP02.phx.gbl...
> Hi,
> Is there a wahy to get AD user info in a SP?
> I need a list of AD users with name, login name and email.
> Thanks.
> George.
>|||Microsoft wrote:
> Hi,
> Is there a wahy to get AD user info in a SP?
> I need a list of AD users with name, login name and email.
Getting the name and login name is possible. But since email is a
multivalued field, it can't be done out of the box.
http://articles.techrepublic.com.com/5100-6345_11-5259887.html|||Hi.
EXEC sp_addlinkedserver 'ADSI', 'Active Directory Services 2.5',
'ADSDSOObject', 'adsdatasource'
SELECT *
FROM OPENQUERY (ADSI, 'SELECT givenName, sn FROM ''LDAP://
DC=DOMAIN,DC=COM''
where objectcategory=''User''')
After time of trying to do best thing in my query (and I succed), i found
this one (this is very useful):
http://www.atlantamdf.com/presentations/AtlantaMDF_111201_examples.txt
Second solution is, as I say earlier, to do some code in C# and call it from
SQL as assembly (try to modify this as you wish):
string rootQuery = LDAP://DC=DOMAINNAME, DC=COM;
DirectoryEntry root = new DirectoryEntry(rootQuery);
DirectorySearcher dirSearch = new DirectorySearcher(root);
//dirSearch.Filter = String.Format("(cn={0})",
"Administrators");
dirSearch.Filter = String.Format("(objectClass=user)");
SearchResultCollection results = dirSearch.FindAll();
ArrayList userNames = new ArrayList();
if (results != null)
{
foreach (SearchResult result in results)
{
for (int i = 0; i < result.Properties["name"].Count;
i++)
{
string user = (string)result.Properties["name"][i];
Console.WriteLine(user);
}
}
}
Console.ReadLine();
Mladen.
"Microsoft" <g2@.bla.cl> wrote in message
news:OzjHniWOHHA.3668@.TK2MSFTNGP02.phx.gbl...
> Hi,
> Is there a wahy to get AD user info in a SP?
> I need a list of AD users with name, login name and email.
> Thanks.
> George.
>
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment