SQL Server Performance

Active Directory and sql server

Discussion in 'General Developer Questions' started by rajkolli_2000, Feb 16, 2006.

  1. rajkolli_2000 New Member

    Hi all,

    i want to delete a user from active directory using sql server query , is it possible or not....

    can anybody help me out....


    Regards
    rajesh.
  2. Adriaan New Member

    If there's a command-line statement that you can enter in a DOS box, then you can execute that same statement through EXEC master.dbo.xp_cmdshell - you'll need proper permissions on the server level, but I figure you already knew that.

    Not sure that it would be wise, though - you should use the proper tools to do this.

    There's also a bunch of stored procedures whose names start with sp_OA, that help you manipulate OLE objects.
  3. Tahsin New Member

    Try this:

    Adriaan's code + 'dsrm ObjectDN'
    where ObjectDN is the name of the user object to be deleted. You can get a list of the parameters for dsrm by typing dsrm/? in DOS

    Let me know if this works. I can't seem to post with the xp command statement, I keep getting an error. Anybody know why?

    - Tahsin


    quote:Originally posted by Adriaan

    If there's a command-line statement that you can enter in a DOS box, then you can execute that same statement through EXEC master.dbo.xp_cmdshell - you'll need proper permissions on the server level, but I figure you already knew that.

    Not sure that it would be wise, though - you should use the proper tools to do this.

    There's also a bunch of stored procedures whose names start with sp_OA, that help you manipulate OLE objects.
  4. Adriaan New Member

    Tahsin, it's a bug in the forum software - you can't post xp_cmdshell as a single word (I cheated here by inserting bold markers between _ and c).
  5. Madhivanan Moderator

  6. FrankKalis Moderator

  7. FrankKalis Moderator

  8. FrankKalis Moderator

    Sorry, that one was another test, that should have failed. [<img src='/community/emoticons/emotion-1.gif' alt=':)' />]<br /><br />--<br />Frank Kalis<br />Microsoft SQL Server MVP<br /<a target="_blank" href=http://www.insidesql.de>http://www.insidesql.de</a><br />Heute schon gebloggt?<a target="_blank" href=http://www.insidesql.de/blogs>http://www.insidesql.de/blogs</a><br />
  9. Madhivanan Moderator

    <blockquote id="quote"><font size="1" face="Verdana, Arial, Helvetica" id="quote">quote:<hr height="1" noshade id="quote"><i>Originally posted by FrankKalis</i><br /><br />Sorry, that one was another test, that should have failed. [<img src='/community/emoticons/emotion-1.gif' alt=':)' />]<br /><br />--<br />Frank Kalis<br />Microsoft SQL Server MVP<br /<a target="_blank" href=http://www.insidesql.de>http://www.insidesql.de</a><br />Heute schon gebloggt?<a target="_blank" href=http://www.insidesql.de/blogs>http://www.insidesql.de/blogs</a><br /><br /><hr height="1" noshade id="quote"></font id="quote"></blockquote id="quote"><br />Not only that but also these<br /><br />xp_sendmail<br />xp_servicecontrol<br />xp_snmp_getstate<br />xp_snmp_raisetrap<br /><br />Madhivanan<br /><br />Failing to plan is Planning to fail
  10. FrankKalis Moderator

  11. Madhivanan Moderator

    Test

    xp_grantlogin
    xp_logevent
    xp_loginconfig
    xp_logininfo
    xp_makewebtask
    xp_msver

    Madhivanan

    Failing to plan is Planning to fail
  12. FrankKalis Moderator

  13. Adriaan New Member

    ... to return to the original question -

    Tahsin, the dsrm executable will no be installed on all SQL Server machines. Perhaps it comes standard with Windows Server editions?

    Here's some ADO programming against an LDAP directory, which you might be able to translate into calls to the sp_OA* procedures ... the following was used against a Unix-based LDAP -

    Dim connLDAP As ADODB.Connection
    Dim rsLDAP As ADODB.Recordset

    Dim strColumnNames As String
    strFieldNames = "comma-separated list"

    Set connLDAP = New ADODB.Connection

    connLDAP.Provider = "ADSDSOObject"
    Should correspond to a DLL installed on the machine where this code is running.
    In my case it was a VBA type library (activeds.tlb).


    connLDAP.CursorLocation = adUseClient 'For one-way traffic

    connLDAP.Open "ADs Provider", "uid=login,ou=trusted,ou=top level name, o=whatever", "password?"

    Set rsLDAP = connLDAP.Execute( _
    "<LDAP://LDAP.mydomain.com/o=whatever/ou=whatever/ou=whatever>;" & _
    "(&(ObjectClass=whatever)(uid=*)(!(uid=_))(some field to filter on=*));" & strFieldNames & ";subtree")

  14. Tahsin New Member

    I believe the dsrm executable is native to the server where Active Directory is installed, whether it is Windows 2000 or 2003. I guess I was assuming that Rajesh wanted to query a SQL statement from a place where the command was accessible, but that statement does not necessarily have to be true. The simplest solution would be to run a SP off the server where dsrm is available. Otherwise, I guess vbscript is another possible way to try and remove a user from an LDAP directory service.

    Thanks guys for the input on why I couldn't post the xp_ commands. I guess next time I will try to wrap it around with some HTML characters like Adriaan did.

Share This Page