IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Windows Serveur Discussion :

Information Active Directory


Sujet :

Windows Serveur

  1. #1
    Membre régulier Avatar de silverfab34
    Inscrit en
    Mars 2006
    Messages
    203
    Détails du profil
    Informations personnelles :
    Âge : 44

    Informations forums :
    Inscription : Mars 2006
    Messages : 203
    Points : 91
    Points
    91
    Par défaut Information Active Directory
    Bonjour à tous et bonne année....
    Developpeur Java / J2ee, je suis ignorant en Active Directory....j'ai compris le principe d'installation (dcpromo, DNS, foret etc....) mais ensuite, je souhaiterais savoir comment le prendre en main et le faire pluguer sur un autre reseau...

    Je cherche de la documentation sur AD (site msdn etc....) mais je ne trouve pas mon bonheur !!!
    Si certains ont des infos, elles seront les bienvenues....

    Merci d'avance !

  2. #2
    Membre éprouvé
    Avatar de neuneu1
    Profil pro
    Administrateur systèmes et réseaux
    Inscrit en
    Avril 2007
    Messages
    1 874
    Détails du profil
    Informations personnelles :
    Localisation : France, Morbihan (Bretagne)

    Informations professionnelles :
    Activité : Administrateur systèmes et réseaux

    Informations forums :
    Inscription : Avril 2007
    Messages : 1 874
    Points : 1 194
    Points
    1 194
    Par défaut
    Salut

    Qu entends tu par plugguer, l integrer dans un reseau existant ou en cree un??
    Une porte peut -etre ouverte ou....rouge!!!!:mouarf

  3. #3
    Membre régulier Avatar de silverfab34
    Inscrit en
    Mars 2006
    Messages
    203
    Détails du profil
    Informations personnelles :
    Âge : 44

    Informations forums :
    Inscription : Mars 2006
    Messages : 203
    Points : 91
    Points
    91
    Par défaut
    Je veux me connecter en Java à une annuaire LDAP (AD) ....

    Sauf que j'ai des erreurs dans mon code :

    J'ai posté un sujet dans la section ici

  4. #4
    Membre éprouvé
    Avatar de neuneu1
    Profil pro
    Administrateur systèmes et réseaux
    Inscrit en
    Avril 2007
    Messages
    1 874
    Détails du profil
    Informations personnelles :
    Localisation : France, Morbihan (Bretagne)

    Informations professionnelles :
    Activité : Administrateur systèmes et réseaux

    Informations forums :
    Inscription : Avril 2007
    Messages : 1 874
    Points : 1 194
    Points
    1 194
    Par défaut
    je suis desole mais la c'est du domaine de la programation,

    par contre pour attaque AD , faut etre en compte admin

    a+
    Une porte peut -etre ouverte ou....rouge!!!!:mouarf

  5. #5
    Membre régulier Avatar de silverfab34
    Inscrit en
    Mars 2006
    Messages
    203
    Détails du profil
    Informations personnelles :
    Âge : 44

    Informations forums :
    Inscription : Mars 2006
    Messages : 203
    Points : 91
    Points
    91
    Par défaut
    Oui, c'est ce que je fais !

  6. #6
    Membre éprouvé
    Avatar de neuneu1
    Profil pro
    Administrateur systèmes et réseaux
    Inscrit en
    Avril 2007
    Messages
    1 874
    Détails du profil
    Informations personnelles :
    Localisation : France, Morbihan (Bretagne)

    Informations professionnelles :
    Activité : Administrateur systèmes et réseaux

    Informations forums :
    Inscription : Avril 2007
    Messages : 1 874
    Points : 1 194
    Points
    1 194
    Par défaut
    As tu essaye de faire un petit script vbs pour voir si ca passe

    je sais pas , une creation de users

    a+
    Une porte peut -etre ouverte ou....rouge!!!!:mouarf

  7. #7
    Membre régulier Avatar de silverfab34
    Inscrit en
    Mars 2006
    Messages
    203
    Détails du profil
    Informations personnelles :
    Âge : 44

    Informations forums :
    Inscription : Mars 2006
    Messages : 203
    Points : 91
    Points
    91
    Par défaut
    non en java !!!

    Par contre, je cherche à savoir comment connecter Active Directory sur une base SQL Server ?
    Ma base de reference est SQL Server et je voudrais que le contenu de celle ci soit copier dans AD..........dès qu'une modification se fait, une suppresion ou creation de donnée..........une mise à jour automatique !
    Je ne sais pas trop comment m'y prendre !

  8. #8
    Membre éprouvé
    Avatar de neuneu1
    Profil pro
    Administrateur systèmes et réseaux
    Inscrit en
    Avril 2007
    Messages
    1 874
    Détails du profil
    Informations personnelles :
    Localisation : France, Morbihan (Bretagne)

    Informations professionnelles :
    Activité : Administrateur systèmes et réseaux

    Informations forums :
    Inscription : Avril 2007
    Messages : 1 874
    Points : 1 194
    Points
    1 194
    Par défaut
    Salut

    j ai bien compris que t u fais du Java(blue)..

    Juste un teste en vbs pour voir si tu as pas un probleme serveur ou est ce que c'est le code java qui est pas bon..


    Donc si tu fais un test en vbs avec dc,cn, etc..(par exemple cree un user) et que ca passe peut etre que le probleme via de java..

    si ca passe pas peut etre un probleme reseau ou autre???
    a+
    Une porte peut -etre ouverte ou....rouge!!!!:mouarf

  9. #9
    Membre régulier Avatar de silverfab34
    Inscrit en
    Mars 2006
    Messages
    203
    Détails du profil
    Informations personnelles :
    Âge : 44

    Informations forums :
    Inscription : Mars 2006
    Messages : 203
    Points : 91
    Points
    91
    Par défaut
    Non mais ca fonctionne maintenant !

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    package test;
    
    
    
    //ADConnection - A Java class that encapsulates a JNDI connection to 
    //an Active Directory
    
    //Written by Jeremy E. Mortis  mortis@ucalgary.ca  2002-07-03 
    
    //Note that password changes require an SSL connection to the Active Directory,
    //but other types of calls do not.
    
    //To set up the SSL connection, check out:
    //http://java.sun.com/j2se/1.3/docs/tooldocs/win32/keytool.html
    //http://www.microsoft.com/windows2000/techinfo/planning/security/casetupsteps.asp
    
    import javax.swing.*;
    import java.awt.*;
    import javax.naming.*;
    import javax.naming.directory.*;
    import javax.naming.ldap.*;
    import java.util.*;
    import java.security.*;
    
    public class ADConnection {
    
    	DirContext ldapContext;
    	String baseName = ",CN=Users,DC=si,DC=interne,DC=ca,DC=fr";
    	String serverIP = "myServer";
    	String modelUsername = "template";
    
    	public ADConnection() {
    		try {
    			Hashtable ldapEnv = new Hashtable(11);
    			ldapEnv.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
    			ldapEnv.put(Context.PROVIDER_URL,  "ldap://" + serverIP + ":389");
    			ldapEnv.put(Context.SECURITY_AUTHENTICATION, "simple");
    			ldapEnv.put(Context.SECURITY_PRINCIPAL, "cn=Administrateur" + baseName);
    			ldapEnv.put(Context.SECURITY_CREDENTIALS, "xxxxxx");
    			//ldapEnv.put(Context.SECURITY_PROTOCOL, "ssl");
    			ldapContext = new InitialDirContext(ldapEnv);
    			
    			//InitialDirContext contexte = new InitialDirContext(ldapEnv);
    		}
    		catch (Exception e) {
    			System.out.println(" bind error: " + e);
    			e.printStackTrace();
    			System.exit(-1);
    		}
    	}
    
    	public void createNew(String username, String surname, String givenName) {
    		try {
    			String distinguishedName = "cn=" + username + baseName;
    			Attributes newAttributes = new BasicAttributes(true);
    			Attribute oc = new BasicAttribute("objectclass");
    			oc.add("top");
    			oc.add("person");
    			oc.add("organizationalperson");
    			oc.add("user");
    			newAttributes.put(oc);
    			newAttributes.put(new BasicAttribute("sAMAccountName", username));
    			newAttributes.put(new BasicAttribute("userPrincipalName", username + "@" + serverIP));
    			newAttributes.put(new BasicAttribute("cn", username));
    			newAttributes.put(new BasicAttribute("sn", surname));
    			newAttributes.put(new BasicAttribute("givenName", givenName));
    			newAttributes.put(new BasicAttribute("displayName", givenName + " " + surname));
    			
    			System.out.println("newAttributes " + newAttributes.get("cn"));
    			System.out.println("newAttributes " + newAttributes.get("cn").equals(username));
    			
    			System.out.println("Name: " + username + " Attributes: " + givenName);
    			if (newAttributes.get("cn").equals(username)){
    				System.out.println("test1: ");
    			}
    			else{
    				System.out.println("test2: ");
    			ldapContext.createSubcontext(distinguishedName, newAttributes);
    			}
    		}
    		catch (Exception e) {
    			System.out.println("create error: " + e);
    			e.printStackTrace();
    			System.exit(-1);
    		}
    	}
    	
    	public void deleteLDAP(String username, String surname, String givenName) {
    		try {
    			String distinguishedName = "cn=" + username + baseName;
    			Attributes newAttributes = new BasicAttributes(true);
    			Attribute oc = new BasicAttribute("objectclass");
    			oc.add("top");
    			oc.add("person");
    			oc.add("organizationalperson");
    			oc.add("user");
    			newAttributes.put(oc);
    			newAttributes.put(new BasicAttribute("sAMAccountName", username));
    			newAttributes.put(new BasicAttribute("userPrincipalName", username + "@" + serverIP));
    			newAttributes.put(new BasicAttribute("cn", username));
    			newAttributes.put(new BasicAttribute("sn", surname));
    			newAttributes.put(new BasicAttribute("givenName", givenName));
    			newAttributes.put(new BasicAttribute("displayName", givenName + " " + surname));
    			
    			System.out.println("Name: " + username + " Attributes: " + givenName);
    			
    			ldapContext.destroySubcontext(distinguishedName);
    		}
    		catch (Exception e) {
    			System.out.println("delete error: " + e);
    			e.printStackTrace();
    			System.exit(-1);
    		}
    	}
    	
    	public void modifyLDAP(String username, String surname, String givenName) {
    		try {
    			String distinguishedName = "cn=" + username + baseName;
    			Attributes newAttributes = new BasicAttributes(true);
    			Attribute oc = new BasicAttribute("objectclass");
    			oc.add("top");
    			oc.add("person");
    			oc.add("organizationalperson");
    			oc.add("user");
    			newAttributes.put(oc);
    			newAttributes.put(new BasicAttribute("sAMAccountName", username));
    			newAttributes.put(new BasicAttribute("userPrincipalName", username + "@" + serverIP));
    			newAttributes.put(new BasicAttribute("cn", username));
    			newAttributes.put(new BasicAttribute("sn", surname));
    			newAttributes.put(new BasicAttribute("givenName", givenName));
    			newAttributes.put(new BasicAttribute("displayName", givenName + " " + surname));
    			
    			System.out.println("Name: " + username + " Attributes: " + givenName);
    			
    			int test = 2;
    			ldapContext.modifyAttributes(distinguishedName,test, newAttributes);
    		}
    		catch (Exception e) {
    			System.out.println("delete error: " + e);
    			e.printStackTrace();
    			System.exit(-1);
    		}
    	}
    
    	public void createClone(String username, String surname, String givenName) {
    		try {
    			Attributes modelAttributes = fetch(modelUsername);
    			String distinguishedName = "cn=" + username + baseName;
    			Attributes newAttributes = new BasicAttributes(true);
    			newAttributes.put(modelAttributes.get("objectclass"));
    			newAttributes.put(modelAttributes.get("userAccountControl"));
    			newAttributes.put(new BasicAttribute("sAMAccountName", username));
    			newAttributes.put(new BasicAttribute("userPrincipalName", username + "@" + serverIP));
    			newAttributes.put(new BasicAttribute("cn", username));
    			newAttributes.put(new BasicAttribute("sn", surname));
    			newAttributes.put(new BasicAttribute("givenName", givenName));
    			newAttributes.put(new BasicAttribute("displayName", givenName + " " + surname));
    			System.out.println("distinguishedName: " + distinguishedName + " Attributes: " + newAttributes);
    			ldapContext.createSubcontext(distinguishedName, newAttributes);
    		}
    		catch (Exception e) {
    			System.out.println("create clone error: " + e);
    			e.printStackTrace();
    			System.exit(-1);
    		}
    	}
    
    	public void update(String username) {
    		try {
    			System.out.println("updating...\n");
    			ModificationItem[] mods = new ModificationItem[1];
    			mods[0] = new ModificationItem(DirContext.REPLACE_ATTRIBUTE,
    					new BasicAttribute("description", "java y"));
    			ldapContext.modifyAttributes("cn=" + username + baseName, mods);
    		}
    		catch (Exception e) {
    			System.out.println(" update error: " + e);
    			System.exit(-1);
    		}
    	}
    
    
    	public void updatePassword(String username, String password) {
    		try {
    			System.out.println("updating password...\n");
    			String quotedPassword = "\"" + password + "\"";
    			char unicodePwd[] = quotedPassword.toCharArray();
    			byte pwdArray[] = new byte[unicodePwd.length * 2];
    			for (int i=0; i<unicodePwd.length; i++) {
    				pwdArray[i*2 + 1] = (byte) (unicodePwd[i] >>> 8);
    				pwdArray[i*2 + 0] = (byte) (unicodePwd[i] & 0xff);
    			}
    			System.out.print("encoded password: ");
    			for (int i=0; i<pwdArray.length; i++) {
    				System.out.print(pwdArray[i] + " ");
    			}
    			System.out.println();
    			ModificationItem[] mods = new ModificationItem[1];
    			mods[0] = new ModificationItem(DirContext.REPLACE_ATTRIBUTE,
    					new BasicAttribute("UnicodePwd", pwdArray));
    			ldapContext.modifyAttributes("cn=" + username + baseName, mods);
    		}
    		catch (Exception e) {
    			System.out.println("update password error: " + e);
    			System.exit(-1);
    		}
    	}
    
    	public Attributes fetch(String username) {
    		Attributes attributes = null;
    		try {
    			System.out.println("fetching: " + username);
    			DirContext o = (DirContext)ldapContext.lookup("cn=" + username + baseName);
    			System.out.println("search done\n");
    			attributes = o.getAttributes("");
    			for (NamingEnumeration ae = attributes.getAll(); ae.hasMoreElements();) {
    				Attribute attr = (Attribute)ae.next();
    				String attrId = attr.getID();
    				for (NamingEnumeration vals = attr.getAll(); vals.hasMore();) {
    					String thing = vals.next().toString();
    					System.out.println(attrId + ": " + thing);
    				}
    			}
    		}
    		catch (Exception e) {
    			System.out.println(" fetch error: " + e);
    			System.exit(-1);
    		}
    		return attributes;
    	}
    
    	public static void main(String[] args) {
    		Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());
    		// the keystore that holds trusted root certificates
    		System.setProperty("javax.net.ssl.trustStore", "e:\\ldap\\keystore");
    		System.setProperty("javax.net.debug", "all");
    		ADConnection adc = new ADConnection();
    		//adc.createClone("clone1", "Clone", "Clarissa");
    		//adc.updatePassword("clone1", "xxxx");
    		
    		//adc.createNew("user1", "User", "Joe");
    		adc.modifyLDAP("user1", "User", "Richard");
    		//adc.deleteLDAP("user1", "User", "Joe");
    		
    		
    		//		Attributes a = adc.fetch("clone1");
    	}
    }
    Sauf que je galere pour trouver une methode me permettant de modifier une donnée dans la base, ou alors de verifier qu'un user n'existe pas lorsque j'en creais un !

Discussions similaires

  1. Récupération Information Active Directory
    Par Nickname dans le forum VBScript
    Réponses: 2
    Dernier message: 17/12/2010, 19h53
  2. Récupération d'information à partir de l'Active Directory
    Par lesanglier dans le forum SharePoint
    Réponses: 4
    Dernier message: 16/12/2009, 14h33
  3. Information concernant un utilisateur dans Active directory
    Par liocifer dans le forum VB 6 et antérieur
    Réponses: 1
    Dernier message: 25/03/2009, 19h19
  4. Réponses: 2
    Dernier message: 16/07/2008, 16h36
  5. Réponses: 2
    Dernier message: 05/03/2008, 09h29

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo