September 7, 2006 at 8:45 am
I was wondering if anyone could tell me how to update a field in Active Directory. I can query successfully with the following:
SELECT
givenname As GivenName,sn,[name] As Name, sAMAccountName As DomAcct, employeeNumber As EmpNo,telephoneNumber As PhNumber,
mail As Email
FROM OpenQuery(
ADSI,'<LDAP:// CN=xxx,DC=yyy,DC=zzz,DC=com>;(&(objectCategory=Person)(objectClass=User));
givenname,sn,name, sAMAccountName, userPrincipalName, employeeNumber,
telephoneNumber, UserAccountControl, mail, adspath;subtree')
I tried using:
UPDATE A set department = 'cccc' FROM (The above select clause) A
It didn't work. Any ideas?
September 8, 2006 at 11:54 am
Have you tried creating a Linked Server to AD?
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/adsi/adsi/distributed_query.asp
EXEC sp_addlinkedserver 'ADSI', 'Active Directory Services 2.5', 'ADSDSOObject', 'adsdatasource'
GO
EXEC sp_addlinkedsrvlogin 'ADSI', false, 'DOMAIN\Administrator', 'CN=Administrator,DC=DISTINGUISHED_NAME,DC=com', 'PASSWORD'
GO
September 11, 2006 at 8:44 am
Thank you for resonding! Yes, I did create a linked server for which my query uses successfully. I also added a login to the linked server that has update permission in the Active Directory. I created a VIEW as suggested in the URL that you provided and I can SELECT via the VIEW. If I try:
Update MyView set department = 'cccc' from MyView, I get:
Server: Msg 7390, Level 16, State 1, Line 1
The requested operation could not be performed because the OLE DB provider 'ADSDSOObject' does not support the required transaction interface.
OLE DB error trace [OLE/DB Provider 'ADSDSOObject' IUnknown::QueryInterface returned 0x80004002].
October 24, 2006 at 4:45 pm
I'm researching the possibility of updating Active Directory from SQL Server. Has anyone been able to successfully use an Openquery UPDATE to push data to AD?
Thanks,
Greg
Greg
November 22, 2006 at 10:20 am
Greg,
I see no one has responded to your post yet. Have you been able in the meantime to resolve the problem.
Regards
Ronnie
November 22, 2006 at 10:34 am
Hi Ronnie,
No, I haven't. I'm really just looking for an example to refer to. I'm working on a team trying to figure out how to use employee data in SQL Server to keep Active Directory up-to-date.
Thanks for your reply.
Greg
Greg
November 22, 2006 at 12:37 pm
Ive probably been researching this exact problem for the last two weeks non stop. The only solution I have yet to have seen that comes remotely close to updating ad using sql (not direct update) was by utilising the ldifde.exe utility. Now this is not directly from SQL but could be automated to producee the results were looking for. Im positive it could be accomplished until we find something more permanent.
Check out this article. Not an extremely clean solution but it will work:
https://blogs.pointbridge.com/Blogs/seaman_derek/Lists/Posts/Post.aspx?ID=5
If you do of course find something we can work with please let me know.
Cheers
Ronnie
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply